httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Basant Kukreja <Basant.Kukr...@Sun.COM>
Subject Re: Solaris sed based apache filtering module (mod_sed)
Date Sat, 09 Aug 2008 01:08:26 GMT
Minor changes : Fixed remaining warnings :
* warning: array subscript has type 'char'
* warning: suggest parentheses around assignment used as truth value
* warning C4018: '<' : signed/unsigned mismatch

Here is the diff :
----------------------------------------------------------------
diff -r 071789bf9134 regexp.c
--- a/regexp.c  Sun Jun 29 12:52:34 2008 -0700
+++ b/regexp.c  Fri Aug 08 17:49:35 2008 -0700
@@ -396,6 +396,7 @@ static int _advance(char *lp, char *ep, 
     char *bbeg;
     char neg;
     int ct;
+    int epint; /* int value of *ep */
 
     while (1) {
         neg = 0;
@@ -440,11 +441,15 @@ static int _advance(char *lp, char *ep, 
             return (0);
 
         case CBRA:
-            vars->braslist[*ep++] = lp;
+            epint = (int) *ep;
+            vars->braslist[epint] = lp;
+            ep++;
             continue;
 
         case CKET:
-            vars->braelist[*ep++] = lp;
+            epint = (int) *ep;
+            vars->braelist[epint] = lp;
+            ep++;
             continue;
 
         case CCHR | RNGE:
@@ -516,8 +521,10 @@ static int _advance(char *lp, char *ep, 
             goto star;
 
         case CBACK:
-            bbeg = vars->braslist[*ep];
-            ct = vars->braelist[*ep++] - bbeg;
+            epint = (int) *ep;
+            bbeg = vars->braslist[epint];
+            ct = vars->braelist[epint] - bbeg;
+            ep++;
 
             if (ecmp(bbeg, lp, ct)) {
                 lp += ct;
@@ -526,8 +533,10 @@ static int _advance(char *lp, char *ep, 
             return (0);
 
         case CBACK | STAR:
-            bbeg = vars->braslist[*ep];
-            ct = vars->braelist[*ep++] - bbeg;
+            epint = (int) *ep;
+            bbeg = vars->braslist[epint];
+            ct = vars->braelist[epint] - bbeg;
+            ep++;
             curlp = lp;
             while (ecmp(bbeg, lp, ct))
                 lp += ct;
diff -r 071789bf9134 sed0.c
--- a/sed0.c    Sun Jun 29 12:52:34 2008 -0700
+++ b/sed0.c    Fri Aug 08 17:49:35 2008 -0700
@@ -343,7 +343,7 @@ swit:
             }
             *--tp = '\0';
 
-            if (lpt = search(commands)) {
+            if ((lpt = search(commands)) != NULL) {
                 if (lpt->address) {
                     command_errf(commands, SEDERR_DLMES, commands->linebuf);
                     return -1;
@@ -437,8 +437,8 @@ jtcommon:
             commands->cp--;
 
             if (*commands->cp == '\0') {
-                if (pt = commands->labtab->chain) {
-                    while (pt1 = pt->lb1)
+                if ((pt = commands->labtab->chain) != NULL) {
+                    while ((pt1 = pt->lb1) != NULL)
                         pt = pt1;
                     pt->lb1 = commands->rep;
                 } else
@@ -454,12 +454,12 @@ jtcommon:
             commands->cp--;
             *--tp = '\0';
 
-            if (lpt = search(commands)) {
+            if ((lpt = search(commands)) != NULL) {
                 if (lpt->address) {
                     commands->rep->lb1 = lpt->address;
                 } else {
                     pt = lpt->chain;
-                    while (pt1 = pt->lb1)
+                    while ((pt1 = pt->lb1) != NULL)
                         pt = pt1;
                     pt->lb1 = commands->rep;
                 }
@@ -926,6 +926,7 @@ static char *ycomp(sed_commands_t *comma
 static char *ycomp(sed_commands_t *commands, char *expbuf)
 {
     char    c;
+    int cint; /* integer value of char c */
     char *ep, *tsp;
     int i;
     char    *sp;
@@ -953,11 +954,12 @@ static char *ycomp(sed_commands_t *comma
             sp++;
             c = '\n';
         }
-        if((ep[c] = *tsp++) == '\\' && *tsp == 'n') {
-            ep[c] = '\n';
+        cint = (int) c;
+        if((ep[cint] = *tsp++) == '\\' && *tsp == 'n') {
+            ep[cint] = '\n';
             tsp++;
         }
-        if(ep[c] == commands->sseof || ep[c] == '\0') {
+        if(ep[cint] == commands->sseof || ep[cint] == '\0') {
             command_errf(commands, SEDERR_TSNTSS, commands->linebuf);
         }
     }
diff -r 071789bf9134 sed1.c
--- a/sed1.c    Sun Jun 29 12:52:34 2008 -0700
+++ b/sed1.c    Fri Aug 08 17:49:35 2008 -0700
@@ -152,7 +152,7 @@ static void grow_gen_buffer(sed_eval_t *
  */
 static void appendmem_to_linebuf(sed_eval_t *eval, const char* sz, int len)
 {
-    int reqsize = (eval->lspend - eval->linebuf) + len;
+    unsigned int reqsize = (eval->lspend - eval->linebuf) + len;
     if (eval->lsize < reqsize) {
         grow_line_buffer(eval, reqsize);
     }
@@ -186,7 +186,7 @@ static void append_to_holdbuf(sed_eval_t
 static void append_to_holdbuf(sed_eval_t *eval, const char* sz)
 {
     int len = strlen(sz);
-    int reqsize = (eval->hspend - eval->holdbuf) + len + 1;
+    unsigned int reqsize = (eval->hspend - eval->holdbuf) + len + 1;
     if (eval->hsize <= reqsize) {
         grow_hold_buffer(eval, reqsize);
     }
@@ -210,7 +210,7 @@ static void append_to_genbuf(sed_eval_t 
 static void append_to_genbuf(sed_eval_t *eval, const char* sz, char **gspend)
 {
     int len = strlen(sz);
-    int reqsize = (*gspend - eval->genbuf) + len + 1;
+    unsigned int reqsize = (*gspend - eval->genbuf) + len + 1;
     if (eval->gsize < reqsize) {
         grow_gen_buffer(eval, reqsize, gspend);
     }
@@ -225,7 +225,7 @@ static void copy_to_genbuf(sed_eval_t *e
 static void copy_to_genbuf(sed_eval_t *eval, const char* sz)
 {
     int len = strlen(sz);
-    int reqsize = len + 1;
+    unsigned int reqsize = len + 1;
     if (eval->gsize < reqsize) {
         grow_gen_buffer(eval, reqsize, NULL);
     }
@@ -630,7 +630,7 @@ static apr_status_t dosub(sed_eval_t *ev
     sp = eval->genbuf;
     rp = rhsbuf;
     sp = place(eval, sp, lp, step_vars->loc1);
-    while(c = *rp++) {
+    while ((c = *rp++) != 0) {
         if (c == '&') {
             sp = place(eval, sp, step_vars->loc1, step_vars->loc2);
             if (sp == NULL)
@@ -667,7 +667,7 @@ static char *place(sed_eval_t *eval, cha
 {
     char *sp = asp;
     int n = al2 - al1;
-    int reqsize = (sp - eval->genbuf) + n + 1;
+    unsigned int reqsize = (sp - eval->genbuf) + n + 1;
 
     if (eval->gsize < reqsize) {
         grow_gen_buffer(eval, reqsize, &sp);
@@ -726,7 +726,7 @@ static apr_status_t command(sed_eval_t *
             break;
 
         case EQCOM:
-            length = apr_snprintf(sz, sizeof(sz), "%lld", eval->lnum);
+            length = apr_snprintf(sz, sizeof(sz), "%d", (int) eval->lnum);
             wline(eval, sz, length);
             break;
 
@@ -766,7 +766,7 @@ static apr_status_t command(sed_eval_t *
                 if((unsigned char)*p1 >= 040) {
                     if(*p1 == 0177) {
                         p3 = rub;
-                        while(*p2++ = *p3++)
+                        while ((*p2++ = *p3++) != 0)
                             if(p2 >= eval->lcomend) {
                                 *p2 = '\\';
                                 wline(eval, eval->genbuf,
@@ -812,7 +812,7 @@ static apr_status_t command(sed_eval_t *
                     }
                 } else {
                     p3 = trans[(unsigned char)*p1-1];
-                    while(*p2++ = *p3++)
+                    while ((*p2++ = *p3++) != 0)
                         if(p2 >= eval->lcomend) {
                             *p2 = '\\';
                             wline(eval, eval->genbuf, strlen(eval->genbuf));
@@ -907,7 +907,7 @@ static apr_status_t command(sed_eval_t *
         case YCOM: 
             p1 = eval->linebuf;
             p2 = ipc->re1;
-            while(*p1 = p2[(unsigned char)*p1])    p1++;
+            while((*p1 = p2[(unsigned char)*p1]) != 0)    p1++;
             break;
     }
     return APR_SUCCESS;
----------------------------------------------------------------

Mime
View raw message