]> git.armaanb.net Git - mmenu.git/commitdiff
Cast i to size_t type
authorArmaan Bhojwani <me@armaanb.net>
Sun, 9 May 2021 03:34:27 +0000 (23:34 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 9 May 2021 03:34:27 +0000 (23:34 -0400)
This doesn't really increase safety because logically i could never be
negative, but at least it suppresses the compiler warnings.

mmenu.c

diff --git a/mmenu.c b/mmenu.c
index b00af5af1b2d7ee11962f2c003fb7559b50c53f4..ed9f339bfdd0fcecaa0682a7df9195dae9523026 100644 (file)
--- a/mmenu.c
+++ b/mmenu.c
@@ -76,7 +76,7 @@ main(int argc, char *argv[])
 
        // Extract text from between HTML tags
        int j = 1;
-       for (int i = 345; i < strlen(chunk.memory); i++) {
+       for (int i = 345; (size_t)i < strlen(chunk.memory); i++) {
                char c = chunk.memory[i];
                if (c == '<') intag = true;
                if (!intag) {
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
        char *nl = (char *) calloc(1, sizeof(char));
        if (!nl) memfail();
 
-       for (int i = 0; i < strlen(outp) - 1; i++) {
+       for (int i = 0; (size_t)i < strlen(outp) - 1; i++) {
                if (outp[i] == '\n' && outp[i+1] == '\n') i+=4;
                nl = (char *) realloc(nl, i);
                if (!nl) memfail();