From dca65d1a2389ed2cafca37828fe78de46758d37c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jun 2008 06:14:25 +0300 Subject: [PATCH] dselect: Fix compilation warnings Surround boolean expressions with parenthesis. Switch a for with an empty body into a while. --- ChangeLog | 16 ++++++++++++++++ dselect/basecmds.cc | 5 +++-- dselect/baselist.cc | 2 +- dselect/bindings.cc | 35 +++++++++++++++++++++-------------- dselect/main.cc | 11 +++++++---- dselect/methparse.cc | 25 +++++++++++++++---------- dselect/pkgcmds.cc | 9 +++++---- dselect/pkgdepcon.cc | 6 +++--- dselect/pkgsublist.cc | 5 +++-- 9 files changed, 74 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e169246..d2e4b5ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-06-30 Guillem Jover + + * dselect/baselist.cc (baselist::wordwrapinfo): Surround expression + with parenthesis. + * dselect/pkgcmds.cc (packagelist::affectedmatches): Likewise. + (packagelist::affectedrange): Switch a for with an empty body into a + while. + * dselect/basecmds.cc (baselist::displayhelp): Likewise. + * dselect/bindings.cc (keybindings::bind, keybindings::find) + (keybindings::operator(), keybindings::key2name) + (keybindings::name2key): Likewise. + * dselect/main.cc (urq_menu, main): Likewise. + * dselect/methparse.cc (readmethods, getcurrentopt): Likewise. + * dselect/pkgdepcon.cc (packagelist::resolvedepcon): Likewise. + * dselect/pkgsublist.cc (packagelist::alreadydone): Likewise. + 2008-06-30 Guillem Jover * lib/trigdeferred.l: Define YY_NO_INPUT to make flex not include diff --git a/dselect/basecmds.cc b/dselect/basecmds.cc index f76bc09d..7ed3c39f 100644 --- a/dselect/basecmds.cc +++ b/dselect/basecmds.cc @@ -155,7 +155,6 @@ void baselist::displayerror(const char* str) { void baselist::displayhelp(const struct helpmenuentry *helpmenu, int key) { - const struct helpmenuentry *hme; int maxx, maxy, i, y, x, nextkey; getmaxyx(stdscr,maxy,maxx); @@ -163,7 +162,9 @@ void baselist::displayhelp(const struct helpmenuentry *helpmenu, int key) { clearok(stdscr,TRUE); for (;;) { werase(stdscr); - for (hme= helpmenu; hme->key && hme->key != key; hme++); + const struct helpmenuentry *hme = helpmenu; + while (hme->key && hme->key != key) + hme++; if (hme->key) { attrset(helpscreen_attr); mvaddstr(1,0, gettext(hme->msg->text)); diff --git a/dselect/baselist.cc b/dselect/baselist.cc index 8ba7ff02..a43aca07 100644 --- a/dselect/baselist.cc +++ b/dselect/baselist.cc @@ -328,7 +328,7 @@ void baselist::wordwrapinfo(int offset, const char *m) { const char *p= strchr(m,'\n'); int l= p ? (int)(p-m) : strlen(m); while (l && isspace(m[l-1])) l--; - if (!l || *m == '.' && l == 1) { + if (!l || (*m == '.' && l == 1)) { if (wrapping) waddch(infopad,'\n'); waddch(infopad,'\n'); wrapping= 0; diff --git a/dselect/bindings.cc b/dselect/bindings.cc index d6f32a74..b77a2988 100644 --- a/dselect/bindings.cc +++ b/dselect/bindings.cc @@ -44,15 +44,18 @@ keybindings::keybindings(const interpretation *ints, const orgbinding *orgbindin int keybindings::bind(int key, const char *action) { if (key == -1) return 0; - const interpretation *interp; - for (interp=interps; interp->action && strcmp(interp->action,action); interp++); + const interpretation *interp = interps; + while (interp->action && strcmp(interp->action, action)) + interp++; if (!interp->action) return 0; - const description *desc; - for (desc=descriptions; desc->action && strcmp(desc->action,action); desc++); + const description *desc = descriptions; + while (desc->action && strcmp(desc->action, action)) + desc++; - binding *bind; - for (bind=bindings; bind && bind->key != key; bind=bind->next); + binding *bind = bindings; + while (bind && bind->key != key) + bind = bind->next; if (!bind) { bind= new binding; @@ -66,8 +69,9 @@ int keybindings::bind(int key, const char *action) { } const char *keybindings::find(const char *action) { - binding *b; - for (b=bindings; b && strcmp(action,b->interp->action); b=b->next); + binding *b = bindings; + while (b && strcmp(action, b->interp->action)) + b = b->next; if (!b) return _("[not bound]"); const char *n= key2name(b->key); if (n) return n; @@ -77,8 +81,9 @@ const char *keybindings::find(const char *action) { } const keybindings::interpretation *keybindings::operator()(int key) { - binding *b; - for (b=bindings; b && b->key != key; b=b->next); + binding *b = bindings; + while (b && b->key != key) + b = b->next; if (!b) return 0; return b->interp; } @@ -105,14 +110,16 @@ const char **keybindings::describenext() { } const char *keybindings::key2name(int key) { - const keyname *search; - for (search=keynames; search->key != -1 && search->key != key; search++); + const keyname *search = keynames; + while (search->key != -1 && search->key != key) + search++; return search->kname; } int keybindings::name2key(const char *name) { - const keyname *search; - for (search=keynames; search->kname && strcasecmp(search->kname,name); search++); + const keyname *search = keynames; + while (search->kname && strcasecmp(search->kname, name)) + search++; return search->key; } diff --git a/dselect/main.cc b/dselect/main.cc index ac277e93..7b631f9b 100644 --- a/dselect/main.cc +++ b/dselect/main.cc @@ -414,7 +414,7 @@ int refreshmenu(void) { urqresult urq_menu(void) { #define C(x) ((x)-'a'+1) - int entries, c, i; + int entries, c; entries= refreshmenu(); int cursor=0; dme(0,1); @@ -460,7 +460,9 @@ urqresult urq_menu(void) { } } else if (isalpha(c)) { c= tolower(c); - for (i=0; icommand && strcmp(me->command,a); me++); + const menuentry *me = menuentries; + while (me->command && strcmp(me->command, a)) + me++; if (!me->command) badusage(_("unknown action string `%.50s'"),a); me->fn(); } diff --git a/dselect/methparse.cc b/dselect/methparse.cc index 1f49c2c2..74a6f540 100644 --- a/dselect/methparse.cc +++ b/dselect/methparse.cc @@ -65,13 +65,13 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) { }; const char *const *ccpp; int methodlen, c, baselen; - char *p, *pathinmeth, *pathbuf, *pathmeth; + char *pathinmeth, *pathbuf, *pathmeth; DIR *dir; FILE *names, *descfile; struct dirent *dent; struct varbuf vb; method *meth; - dselect_option *opt, **optinsert; + dselect_option *opt; struct stat stab; baselen= strlen(pathbase); @@ -93,7 +93,9 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) { if (debug) fprintf(debug,"readmethods(`%s',...) considering `%s' ...\n", pathbase,dent->d_name); if (c != '_' && !isalpha(c)) continue; - for (p= dent->d_name+1; (c= *p) != 0 && isalnum(c) && c != '_'; p++); + char *p = dent->d_name + 1; + while ((c = *p) != 0 && isalnum(c) && c != '_') + p++; if (c) continue; methodlen= strlen(dent->d_name); if (methodlen > IMETHODMAXLEN) @@ -205,9 +207,10 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) { opt->description ? "`...'" : "null", opt->description ? (long) strlen(opt->description) : -1, opt->meth->name, opt->meth->path, opt->meth->pathinmeth); - for (optinsert= optionspp; - *optinsert && strcmp(opt->index,(*optinsert)->index) > 0; - optinsert= &(*optinsert)->next); + + dselect_option **optinsert = optionspp; + while (*optinsert && strcmp(opt->index, (*optinsert)->index) > 0) + optinsert = &(*optinsert)->next; opt->next= *optinsert; *optinsert= opt; (*nread)++; @@ -229,8 +232,6 @@ void getcurrentopt() { int l; int admindirlen; char *p; - method *meth; - dselect_option *opt; if (!methoptfile) { admindirlen= strlen(admindir); @@ -259,10 +260,14 @@ void getcurrentopt() { if (debug) fprintf(debug,"getcurrentopt() cmethopt space\n"); *p++= 0; if (debug) fprintf(debug,"getcurrentopt() cmethopt meth name `%s'\n", methoptbuf); - for (meth= methods; meth && strcmp(methoptbuf,meth->name); meth= meth->next); + method *meth = methods; + while (meth && strcmp(methoptbuf, meth->name)) + meth = meth->next; if (!meth) return; if (debug) fprintf(debug,"getcurrentopt() cmethopt meth found; opt `%s'\n",p); - for (opt= options; opt && (opt->meth != meth || strcmp(p,opt->name)); opt= opt->next); + dselect_option *opt = options; + while (opt && (opt->meth != meth || strcmp(p, opt->name))) + opt = opt->next; if (!opt) return; if (debug) fprintf(debug,"getcurrentopt() cmethopt opt found\n"); coption= opt; diff --git a/dselect/pkgcmds.cc b/dselect/pkgcmds.cc index 32744c89..1fce22c4 100644 --- a/dselect/pkgcmds.cc +++ b/dselect/pkgcmds.cc @@ -48,8 +48,8 @@ int packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewit } if (comparewith->priority != pkginfo::pri_unset && (comparewith->priority != pkg->priority || - comparewith->priority == pkginfo::pri_other && - strcasecmp(comparewith->otherpriority,pkg->otherpriority))) + (comparewith->priority == pkginfo::pri_other && + strcasecmp(comparewith->otherpriority, pkg->otherpriority)))) return 0; if (comparewith->section && strcasecmp(comparewith->section, @@ -65,8 +65,9 @@ void packagelist::affectedrange(int *startp, int *endp) { *endp= cursorline+1; return; } - int index; - for (index= cursorline; index < nitems && !table[index]->pkg->name; index++); + int index = cursorline; + while (index < nitems && !table[index]->pkg->name) + index++; if (index >= nitems) { *startp= *endp= cursorline; return; diff --git a/dselect/pkgdepcon.cc b/dselect/pkgdepcon.cc index eea4f836..0f3140fc 100644 --- a/dselect/pkgdepcon.cc +++ b/dselect/pkgdepcon.cc @@ -235,9 +235,9 @@ int packagelist::resolvedepcon(dependency *depends) { fixbyupgrade= 0; - for (possi= depends->list; - possi && !deppossatisfied(possi,&fixbyupgrade); - possi= possi->next); + possi = depends->list; + while (possi && !deppossatisfied(possi, &fixbyupgrade)) + possi = possi->next; if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): depends found %s\n", this,depends, diff --git a/dselect/pkgsublist.cc b/dselect/pkgsublist.cc index 7046b6fe..8f17f712 100644 --- a/dselect/pkgsublist.cc +++ b/dselect/pkgsublist.cc @@ -78,9 +78,10 @@ void packagelist::add(pkginfo *pkg, const char *extrainfo, showpriority showimp) } int packagelist::alreadydone(doneent **done, void *check) { - doneent *search; + doneent *search = *done; - for (search= *done; search && search->dep != check; search=search->next); + while (search && search->dep != check) + search = search->next; if (search) return 1; if (debug) fprintf(debug,"packagelist[%p]::alreadydone(%p,%p) new\n", this,done,check); -- 2.39.5