Use sizeof("...")-1 throughout.
authorjbj <devnull@localhost>
Tue, 7 Sep 1999 22:49:45 +0000 (22:49 +0000)
committerjbj <devnull@localhost>
Tue, 7 Sep 1999 22:49:45 +0000 (22:49 +0000)
CVS patchset: 3268
CVS date: 1999/09/07 22:49:45

build/files.c
build/parsePreamble.c
build/parsePrep.c
build/parseSpec.c
lib/cpio.c
lib/ftp.c
lib/header.c
lib/oldheader.c

index e9b78bf..7ad5387 100644 (file)
@@ -545,9 +545,9 @@ static int parseForLang(char *buf, struct FileList *fl)
        np = pe - p;
        
        /* Sanity check on locale lengths */
-       if (np < 1 || (np == 1 && *p != 'C') || np >= 16) {
+       if (np < 1 || (np == 1 && *p != 'C') || np >= 32) {
            rpmError(RPMERR_BADSPEC, _("Unusual locale length: \"%.*s\" in %%lang(%s)"),
-               np, p, q);
+               (int)np, p, q);
            fl->processingFailed = 1;
            return RPMERR_BADSPEC;
        }
@@ -557,7 +557,7 @@ static int parseForLang(char *buf, struct FileList *fl)
            if (strncmp(fl->currentLangs[i], p, np))
                continue;
            rpmError(RPMERR_BADSPEC, _("Duplicate locale %.*s in %%lang(%s)"),
-               np, p, q);
+               (int)np, p, q);
            fl->processingFailed = 1;
            return RPMERR_BADSPEC;
        }
index a8e1207..78d33dd 100644 (file)
@@ -254,9 +254,9 @@ static int readIcon(Header h, const char *file)
        goto exit;
     }
 
-    if (! strncmp(icon, "GIF", 3)) {
+    if (! strncmp(icon, "GIF", sizeof("GIF")-1)) {
        headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, statbuf.st_size);
-    } else if (! strncmp(icon, "/* XPM", 6)) {
+    } else if (! strncmp(icon, "/* XPM", sizeof("/* XPM")-1)) {
        headerAddEntry(h, RPMTAG_XPM, RPM_BIN_TYPE, icon, statbuf.st_size);
     } else {
        rpmError(RPMERR_BADSPEC, _("Unknown icon type: %s"), file);
index 8d7c20e..d1bf046 100644 (file)
@@ -362,7 +362,7 @@ static int doPatchMacro(Spec spec, char *line)
                         spec->lineNum, spec->line);
                return RPMERR_BADSPEC;
            }
-       } else if (!strncmp(s, "-p", 2)) {
+       } else if (!strncmp(s, "-p", sizeof("-p")-1)) {
            /* unfortunately, we must support -pX */
            if (! strchr(" \t\n", s[2])) {
                s = s + 2;
@@ -456,9 +456,9 @@ int parsePrep(Spec spec)
     saveLines = lines;
     while (*lines) {
        res = 0;
-       if (! strncmp(*lines, "%setup", 6)) {
+       if (! strncmp(*lines, "%setup", sizeof("%setup")-1)) {
            res = doSetupMacro(spec, *lines);
-       } else if (! strncmp(*lines, "%patch", 6)) {
+       } else if (! strncmp(*lines, "%patch", sizeof("%patch")-1)) {
            res = doPatchMacro(spec, *lines);
        } else {
            appendLineStringBuf(spec->prep, *lines);
index 5fa216e..41a6c69 100644 (file)
@@ -224,19 +224,19 @@ retry:
     SKIPSPACE(s);
 
     match = -1;
-    if (! strncmp("%ifarch", s, 7)) {
+    if (! strncmp("%ifarch", s, sizeof("%ifarch")-1)) {
        s += 7;
        match = matchTok(arch, s);
-    } else if (! strncmp("%ifnarch", s, 8)) {
+    } else if (! strncmp("%ifnarch", s, sizeof("%ifnarch")-1)) {
        s += 8;
        match = !matchTok(arch, s);
-    } else if (! strncmp("%ifos", s, 5)) {
+    } else if (! strncmp("%ifos", s, sizeof("%ifos")-1)) {
        s += 5;
        match = matchTok(os, s);
-    } else if (! strncmp("%ifnos", s, 6)) {
+    } else if (! strncmp("%ifnos", s, sizeof("%ifnos")-1)) {
        s += 6;
        match = !matchTok(os, s);
-    } else if (! strncmp("%if", s, 3)) {
+    } else if (! strncmp("%if", s, sizeof("%if")-1)) {
        s += 3;
         match = parseExpressionBoolean(spec, s);
        if (match < 0) {
@@ -244,7 +244,7 @@ retry:
                     ofi->fileName, ofi->lineNum, match);
            return RPMERR_BADSPEC;
        }
-    } else if (! strncmp("%else", s, 5)) {
+    } else if (! strncmp("%else", s, sizeof("%else")-1)) {
        s += 5;
        if (! spec->readStack->next) {
            /* Got an else with no %if ! */
@@ -255,7 +255,7 @@ retry:
        spec->readStack->reading =
            spec->readStack->next->reading && ! spec->readStack->reading;
        spec->line[0] = '\0';
-    } else if (! strncmp("%endif", s, 6)) {
+    } else if (! strncmp("%endif", s, sizeof("%endif")-1)) {
        s += 6;
        if (! spec->readStack->next) {
            /* Got an end with no %if ! */
@@ -267,7 +267,7 @@ retry:
        spec->readStack = spec->readStack->next;
        free(rl);
        spec->line[0] = '\0';
-    } else if (! strncmp("%include", s, 8)) {
+    } else if (! strncmp("%include", s, sizeof("%include")-1)) {
        char *fileName, *endFileName, *p;
 
        s += 8;
index 0a2543e..e113abe 100644 (file)
@@ -194,8 +194,8 @@ static int getNextHeader(CFD_t * cfd, struct cpioHeader * chPtr) {
     if (ourread(cfd, &physHeader, PHYS_HDR_SIZE) != PHYS_HDR_SIZE) 
        return CPIOERR_READ_FAILED;
 
-    if (strncmp(CPIO_CRC_MAGIC, physHeader.magic, strlen(CPIO_CRC_MAGIC)) &&
-       strncmp(CPIO_NEWC_MAGIC, physHeader.magic, strlen(CPIO_NEWC_MAGIC)))
+    if (strncmp(CPIO_CRC_MAGIC, physHeader.magic, sizeof(CPIO_CRC_MAGIC)-1) &&
+       strncmp(CPIO_NEWC_MAGIC, physHeader.magic, sizeof(CPIO_NEWC_MAGIC)-1))
        return CPIOERR_BAD_MAGIC;
 
     GET_NUM_FIELD(physHeader.inode, chPtr->inode);
index e86c5e5..baade99 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -129,7 +129,7 @@ static int checkResponse(int fd, int secs, int *ecp, char ** str) {
                *se++ = '\0';
 
                /* HTTP: look for "HTTP/1.1 123 ..." */
-               if (!strncmp(s, "HTTP", 4)) {
+               if (!strncmp(s, "HTTP", sizeof("HTTP")-1)) {
                        char *e;
                        if ((e = strchr(s, ' ')) != NULL) {
                            e++;
@@ -144,10 +144,10 @@ static int checkResponse(int fd, int secs, int *ecp, char ** str) {
                /* FTP: look for "123-" and/or "123 " */
                if (strchr("0123456789", *s)) {
                        if (errorCode[0]) {
-                           if (!strncmp(s, errorCode, 3) && s[3] == ' ')
+                           if (!strncmp(s, errorCode, sizeof("123")-1) && s[3] == ' ')
                                doesContinue = 0;
                        } else {
-                           strncpy(errorCode, s, 3);
+                           strncpy(errorCode, s, sizeof("123")-1);
                            errorCode[3] = '\0';
                            if (s[3] != '-') {
                                doesContinue = 0;
index bb494b6..c0ebe97 100644 (file)
@@ -1363,7 +1363,7 @@ static void findTag(char * name, const struct headerTagTableEntry * tags,
     *tagMatch = NULL;
     *extMatch = NULL;
 
-    if (strncmp("RPMTAG_", name, 7)) {
+    if (strncmp("RPMTAG_", name, sizeof("RPMTAG_")-1)) {
        tagname = alloca(strlen(name) + 10);
        strcpy(tagname, "RPMTAG_");
        strcat(tagname, name);
index 3916246..ec4a730 100644 (file)
@@ -197,22 +197,22 @@ char * oldhdrParseSpec(struct oldrpmHeader * header, struct oldrpmHeaderSpec * s
 
     spec->fileCount = 0;
     for (strptr = lines; *strptr; strptr++) {
-       if (!strncmp("%speci", *strptr, 6)) {
+       if (!strncmp("%speci", *strptr, sizeof("%speci")-1)) {
            state = FILELIST;
            files = strptr + 1;
-       } else if (!strncmp("%postun", *strptr, 7)) {
+       } else if (!strncmp("%postun", *strptr, sizeof("%postun")-1)) {
            state = POSTUN;
            str = &spec->postun;
        }
-       else if (!strncmp("%preun", *strptr, 6)) {
+       else if (!strncmp("%preun", *strptr, sizeof("%preun")-1)) {
            state = PREUN;
            str = &spec->preun;
        }
-       else if (!strncmp("%post", *strptr, 5)) {
+       else if (!strncmp("%post", *strptr, sizeof("%post")-1)) {
            state = POSTIN;
            str = &spec->postin;
        }
-       else if (!strncmp("%pre", *strptr, 4)) {
+       else if (!strncmp("%pre", *strptr, sizeof("%pre")-1)) {
            state = PREIN;
            str = &spec->prein;
        }