]> granicus.if.org Git - curl/commitdiff
tool_urlglob.c: Silence warning C6293: Ill-defined for-loop
authorMarc Hoersken <info@marc-hoersken.de>
Sun, 14 Dec 2014 21:45:06 +0000 (22:45 +0100)
committerMarc Hoersken <info@marc-hoersken.de>
Sun, 14 Dec 2014 21:45:06 +0000 (22:45 +0100)
The >= 0 is actually not required, since i underflows and
the for-loop is stopped using the < condition, but this
makes the VS2012 compiler and code analysis happy.

src/tool_urlglob.c

index 36e83c3303aff47f64597905039d39a4e573121e..9dace458d51f272f1fc4c456e069c2437aec22af 100644 (file)
@@ -466,7 +466,7 @@ void glob_cleanup(URLGlob* glob)
   int elem;
 
   /* the < condition is required since i underflows! */
-  for(i = glob->size - 1; i < glob->size; --i) {
+  for(i = glob->size - 1; i >= 0 && i < glob->size; --i) {
     if((glob->pattern[i].type == UPTSet) &&
        (glob->pattern[i].content.Set.elements)) {
       for(elem = glob->pattern[i].content.Set.size - 1;
@@ -500,7 +500,7 @@ int glob_next_url(char **globbed, URLGlob *glob)
     /* implement a counter over the index ranges of all patterns,
        starting with the rightmost pattern */
     /* the < condition is required since i underflows! */
-    for(i = glob->size - 1; carry && (i < glob->size); --i) {
+    for(i = glob->size - 1; carry && i >= 0 && (i < glob->size); --i) {
       carry = FALSE;
       pat = &glob->pattern[i];
       switch (pat->type) {