From 1cd1eba2ab619afd17228e326dda0a1b1b4c9a2f Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 31 Aug 2009 12:22:53 +0300 Subject: [PATCH] Replace equal/not equal uses of str[n]cmp() with rstreq[n] in fsm & psm --- lib/fsm.c | 16 ++++++++-------- lib/psm.c | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/fsm.c b/lib/fsm.c index 37a22f3..8dc2ba7 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -337,9 +337,9 @@ void * dnlInitIterator(const FSM_t fsm, jlen = strlen(dnl); if (jlen != (dnlen+bnlen+1)) continue; - if (strncmp(dnl, rpmfiDNIndex(fi, dil), dnlen)) + if (!rstreqn(dnl, rpmfiDNIndex(fi, dil), dnlen)) continue; - if (strncmp(dnl+dnlen, rpmfiBNIndex(fi, i), bnlen)) + if (!rstreqn(dnl+dnlen, rpmfiBNIndex(fi, i), bnlen)) continue; if (dnl[dnlen+bnlen] != '/' || dnl[dnlen+bnlen+1] != '\0') continue; @@ -1197,7 +1197,7 @@ static int fsmMkdirs(FSM_t fsm) if (dnlen <= 1) continue; - if (dnlen <= fsm->ldnlen && !strcmp(fsm->path, fsm->ldn)) + if (dnlen <= fsm->ldnlen && rstreq(fsm->path, fsm->ldn)) continue; /* Copy to avoid const on fsm->path. */ @@ -1214,7 +1214,7 @@ static int fsmMkdirs(FSM_t fsm) /* Already validated? */ if (i < fsm->ldnlen && (fsm->ldn[i] == '/' || fsm->ldn[i] == '\0') && - !strncmp(fsm->path, fsm->ldn, i)) + rstreqn(fsm->path, fsm->ldn, i)) { *te = '/'; /* Move pre-existing path marker forward. */ @@ -1324,7 +1324,7 @@ static const char * rpmteTypeString(rpmte te) #define IS_DEV_LOG(_x) \ ((_x) != NULL && strlen(_x) >= (sizeof("/dev/log")-1) && \ - !strncmp((_x), "/dev/log", sizeof("/dev/log")-1) && \ + rstreqn((_x), "/dev/log", sizeof("/dev/log")-1) && \ ((_x)[sizeof("/dev/log")-1] == '\0' || \ (_x)[sizeof("/dev/log")-1] == ';')) @@ -2009,7 +2009,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break; rc = fsmUNSAFE(fsm, FSM_READLINK); errno = saveerrno; if (rc) break; - if (!strcmp(fsm->opath, fsm->rdbuf)) return 0; + if (rstreq(fsm->opath, fsm->rdbuf)) return 0; } } else if (S_ISFIFO(st->st_mode)) { if (S_ISFIFO(ost->st_mode)) return 0; @@ -2081,7 +2081,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break; break; case FSM_LSETFCON: if (fsm->fcontext == NULL || *fsm->fcontext == '\0' - || !strcmp(fsm->fcontext, "<>")) + || rstreq(fsm->fcontext, "<>")) break; rc = lsetfilecon(fsm->path, (security_context_t)fsm->fcontext); if (_fsm_debug && (stage & FSM_SYSCALL)) @@ -2207,7 +2207,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break; case FSM_NEXT: rc = fsmUNSAFE(fsm, FSM_HREAD); if (rc) break; - if (!strcmp(fsm->path, CPIO_TRAILER)) { /* Detect end-of-payload. */ + if (rstreq(fsm->path, CPIO_TRAILER)) { /* Detect end-of-payload. */ fsm->path = _constfree(fsm->path); rc = CPIOERR_HDR_TRAILER; } diff --git a/lib/psm.c b/lib/psm.c index 2d25447..2bee270 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -298,7 +298,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd, } } - if (rootdir && strcmp(rootdir, "/") == 0) + if (rootdir && rstreq(rootdir, "/")) rootdir = NULL; /* Macros need to be added before trying to create directories */ @@ -480,7 +480,7 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t argv, xx = chdir("/"); rootFd = open(".", O_RDONLY, 0); if (rootFd >= 0) { - if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') + if (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/') xx = chroot(rootDir); xx = rpmtsSetChrootDone(ts, 1); } @@ -520,7 +520,7 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t argv, const char *rootDir = rpmtsRootDir(ts); xx = fchdir(rootFd); xx = close(rootFd); - if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') + if (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/') xx = chroot("."); xx = rpmtsSetChrootDone(ts, 0); } @@ -674,7 +674,7 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, if (*argvp == NULL && script == NULL) return RPMRC_OK; - if (*argvp && *argvp[0] && strcmp(*argvp[0], "") == 0) { + if (*argvp && *argvp[0] && rstreq(*argvp[0], "")) { return runLuaScript(psm, h, stag, *argvp, script, arg1, arg2); } rasprintf(&sname, "%s(%s)", tag2sln(stag), rpmteNEVRA(psm->te)); @@ -685,7 +685,7 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, * If a successor node, and ldconfig was just run, don't bother. */ if (ldconfig_path && *argvp != NULL && psm->unorderedSuccessor) { - if (ldconfig_done && !strcmp(*argvp[0], ldconfig_path)) { + if (ldconfig_done && rstreq(*argvp[0], ldconfig_path)) { rpmlog(RPMLOG_DEBUG, "%s: %s skipping redundant \"%s\".\n", psm->stepName, sname, *argvp[0]); free(sname); @@ -700,7 +700,7 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, argvAdd(argvp, "/bin/sh"); ldconfig_done = 0; } else { - ldconfig_done = (ldconfig_path && !strcmp(*argvp[0], ldconfig_path) + ldconfig_done = (ldconfig_path && rstreq(*argvp[0], ldconfig_path) ? 1 : 0); } @@ -722,7 +722,7 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, ARGV_t * argvp, } if (rpmIsDebug() && - (!strcmp(*argvp[0], "/bin/sh") || !strcmp(*argvp[0], "/bin/bash"))) + (rstreq(*argvp[0], "/bin/sh") || rstreq(*argvp[0], "/bin/bash"))) { static const char set_x[] = "set -x\n"; xx = Fwrite(set_x, sizeof(set_x[0]), sizeof(set_x)-1, fd); @@ -906,7 +906,7 @@ static rpmRC handleOneTrigger(const rpmpsm psm, if ((Name = rpmdsN(trigger)) == NULL) continue; /* XXX can't happen */ - if (strcmp(Name, sourceName)) + if (!rstreq(Name, sourceName)) continue; if (!(Flags & psm->sense)) continue; @@ -1585,7 +1585,7 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) && !rpmtsChrootDone(ts) && !psm->chrootDone) { xx = chdir("/"); - if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') + if (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/') if (chroot(rootDir) == -1) { rpmlog(RPMLOG_ERR, _("Unable to change root directory: %m\n")); return -1; @@ -1599,7 +1599,7 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) if (psm->chrootDone) { const char * rootDir = rpmtsRootDir(ts); const char * currDir = rpmtsCurrDir(ts); - if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') + if (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/') rc = chroot("."); psm->chrootDone = 0; (void) rpmtsSetChrootDone(ts, 0); -- 2.7.4