Fix for "tautological" compiler warnings

François Bonzon <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <CAB_cgSLc=1zvR7mJ02Ou2DXV7CNs_ubYcr4UahQ5SpCHAva4+w@mail.gmail.com>
Hi,

I compiled successfully Kannel 1.4.4 on Mac OS X, but noticed these
warnings:


gw/smsc/smpp_pdu.c:908:23: warning: comparison of constant 1024 with
expression of type 'enum SMPP_ERROR_MESSAGES' is always false
      [-Wtautological-constant-out-of-range-compare]
            if (error >= 0x0400 && error <= 0x04FF)
                ~~~~~ ^  ~~~~~~

gw/smsc/smpp_pdu.c:908:42: warning: comparison of constant 1279 with
expression of type 'enum SMPP_ERROR_MESSAGES' is always true
      [-Wtautological-constant-out-of-range-compare]
            if (error >= 0x0400 && error <= 0x04FF)
                                   ~~~~~ ^  ~~~~~~

wmlscript/wsutf8.c:301:13: warning: comparison of unsigned expression < 0
is always false [-Wtautological-compare]
    if (pos < 0 || pos >= string->len)
        ~~~ ^ ~

wap/wsp_headers.c:504:17: warning: comparison of unsigned expression < 0 is
always false [-Wtautological-compare]
    if (timeval < 0) {
        ~~~~~~~ ^ ~


I thought I could fix them. Attached is a patch.

Best,
François
fix-tautological.diff (text/plain, 2.4 KB)
Index: gw/smsc/smpp_pdu.c
===================================================================
--- gw/smsc/smpp_pdu.c	(revision 5104)
+++ gw/smsc/smpp_pdu.c	(working copy)
@@ -534,7 +534,7 @@
     if ((type = decode_integer(data_without_len, 0, 4)) == -1)
         return NULL;
 
-    /* create a coresponding representation structure */
+    /* create a corresponding representation structure */
     pdu = smpp_pdu_create(type, 0);
     if (pdu == NULL)
         return NULL;
@@ -904,10 +904,6 @@
             return "Broadcast Channel Indicator is invalid";
 
         default:
-            /* tell the user that we have a vendor-specific beast here */
-            if (error >= 0x0400 && error <= 0x04FF)
-                return "Vendor-specific error, please refer to your SMPP provider";
-            else
-                return "Unknown/Reserved";
+            return "Unknown/Reserved";
     }
 }
Index: gw/smsc/smpp_pdu.h
===================================================================
--- gw/smsc/smpp_pdu.h	(revision 5104)
+++ gw/smsc/smpp_pdu.h	(working copy)
@@ -155,6 +155,9 @@
 
 /*
  * Some SMPP error messages we come across
+ *
+ * NOTE: When adding a new error message, please add a corresponding entry in
+ * smpp_error_to_string() in smpp_pdu.c.
  */
 enum SMPP_ERROR_MESSAGES {
     SMPP_ESME_ROK = 0x00000000,
@@ -174,7 +177,7 @@
     SMPP_ESME_RINVSYSID = 0x0000000F,
     SMPP_ESME_RCANCELFAIL = 0x00000011,
     SMPP_ESME_RREPLACEFAIL = 0x00000013,
-    SMPP_ESME_RMSGQFUL   = 0x00000014,
+    SMPP_ESME_RMSGQFUL = 0x00000014,
     SMPP_ESME_RINVSERTYP = 0x00000015,
     SMPP_ESME_RINVNUMDESTS = 0x00000033,
     SMPP_ESME_RINVDLNAME = 0x00000034,
Index: wap/wsp_headers.c
===================================================================
--- wap/wsp_headers.c	(revision 5104)
+++ wap/wsp_headers.c	(working copy)
@@ -501,10 +501,6 @@
     }
 
     timeval = unpack_multi_octet_integer(context, length);
-    if (timeval < 0) {
-        warning(0, "WSP headers: cannot unpack date-value.");
-        return NULL;
-    }
 
     return date_format_http(timeval);
 }
Index: wmlscript/wsutf8.c
===================================================================
--- wmlscript/wsutf8.c	(revision 5104)
+++ wmlscript/wsutf8.c	(working copy)
@@ -298,7 +298,7 @@
     unsigned char *data;
     unsigned long ch;
 
-    if (pos < 0 || pos >= string->len)
+    if (pos >= string->len)
         /* Index out range. */
         return 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.