clyver / CS3600-DNS-Server

A DNS client program which given a name to query for and a DNS server to query, send a and receive packets
1 stars 0 forks source link

Dodgy string comparisons #1

Open schmiddy opened 9 years ago

schmiddy commented 9 years ago

Comparing strings using == is dodgy at best, and clang gives complaints for the code in 3600dns.c like:

3600dns.c:510:12: warning: result of comparison against a string literal is
      unspecified (use strncmp instead) [-Wstring-compare]
                if (type == "IP") {
                         ^  ~~~~
3600dns.c:519:12: warning: result of comparison against a string literal is
      unspecified (use strncmp instead) [-Wstring-compare]
                if (type == "CNAME") {
                         ^  ~~~~~~~
3600dns.c:524:12: warning: result of comparison against a string literal is
      unspecified (use strncmp instead) [-Wstring-compare]
                if (type == "MX") {
                         ^  ~~~~
3600dns.c:532:12: warning: result of comparison against a string literal is
      unspecified (use strncmp instead) [-Wstring-compare]
                if (type == "NS") {
Bachmann1234 commented 9 years ago

:heart:

marckrull commented 9 years ago

strncmp, my old friend.

jstnlef commented 9 years ago

Trolls

jstnlef commented 9 years ago

Though, it is good advice

clyver commented 9 years ago

Thanks guys, I'll address this feedback and re-submit. Although, it was due a year ago :stuck_out_tongue_winking_eye: .