From 6281ee4de1edd2882452f3cc0ddff5e8ab94f222 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 7 Sep 1999 22:49:45 +0000 Subject: [PATCH] Use sizeof("...")-1 throughout. CVS patchset: 3268 CVS date: 1999/09/07 22:49:45 --- build/files.c | 6 +++--- build/parsePreamble.c | 4 ++-- build/parsePrep.c | 6 +++--- build/parseSpec.c | 16 ++++++++-------- lib/cpio.c | 4 ++-- lib/ftp.c | 6 +++--- lib/header.c | 2 +- lib/oldheader.c | 10 +++++----- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/build/files.c b/build/files.c index e9b78bf..7ad5387 100644 --- a/build/files.c +++ b/build/files.c @@ -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; } diff --git a/build/parsePreamble.c b/build/parsePreamble.c index a8e1207..78d33dd 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -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); diff --git a/build/parsePrep.c b/build/parsePrep.c index 8d7c20e..d1bf046 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -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); diff --git a/build/parseSpec.c b/build/parseSpec.c index 5fa216e..41a6c69 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -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; diff --git a/lib/cpio.c b/lib/cpio.c index 0a2543e..e113abe 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -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); diff --git a/lib/ftp.c b/lib/ftp.c index e86c5e5..baade99 100644 --- 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; diff --git a/lib/header.c b/lib/header.c index bb494b6..c0ebe97 100644 --- a/lib/header.c +++ b/lib/header.c @@ -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); diff --git a/lib/oldheader.c b/lib/oldheader.c index 3916246..ec4a730 100644 --- a/lib/oldheader.c +++ b/lib/oldheader.c @@ -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; } -- 2.7.4