The following commit has been merged in the master branch:
commit d33cf5c4aaf22345a320f292d2a3205e25986aaf
Author: Guillem Jover <[email protected]>
Date: Wed Sep 12 07:43:16 2012 +0200
Avoid assignments in C conditionals
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 7655158..c90863a 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -366,7 +366,8 @@ controlextractvextract(int admin, enum dpkg_tar_options
taroptions,
{
const char *debar, *dir;
- if (!(debar= *argv++))
+ debar = *argv++;
+ if (debar == NULL)
badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
dir = *argv++;
if (!dir) {
@@ -387,7 +388,8 @@ do_fsystarfile(const char *const *argv)
{
const char *debar;
- if (!(debar= *argv++))
+ debar = *argv++;
+ if (debar == NULL)
badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
if (*argv)
badusage(_("--%s takes only one argument (.deb
filename)"),cipaction->olong);
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index e11cc32..65cba69 100644
--- a/dpkg-split/queue.c
+++ b/dpkg-split/queue.c
@@ -138,7 +138,8 @@ do_auto(const char *const *argv)
if (!opt_outputfile)
badusage(_("--auto requires the use of the --output option"));
- if (!(partfile= *argv++) || *argv)
+ partfile = *argv++;
+ if (partfile == NULL || *argv)
badusage(_("--auto requires exactly one part file argument"));
refi= nfmalloc(sizeof(struct partqueue));
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index e92564c..4c363c3 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -523,7 +523,8 @@ packagelist::checksearch(char *rx)
}
}
- if ((r=regcomp(&searchfsm, rx, opt))!=0) {
+ r = regcomp(&searchfsm, rx, opt);
+ if (r != 0) {
displayerror(_("error in regular expression"));
return false;
}
diff --git a/lib/dpkg/mlib.c b/lib/dpkg/mlib.c
index 17a0a91..fac1378 100644
--- a/lib/dpkg/mlib.c
+++ b/lib/dpkg/mlib.c
@@ -126,7 +126,8 @@ setcloexec(int fd, const char *fn)
{
int f;
- if ((f=fcntl(fd, F_GETFD))==-1)
+ f = fcntl(fd, F_GETFD);
+ if (f == -1)
ohshite(_("unable to read filedescriptor flags for %.250s"),fn);
if (fcntl(fd, F_SETFD, (f|FD_CLOEXEC))==-1)
ohshite(_("unable to set close-on-exec flag for %.250s"),fn);
diff --git a/lib/dpkg/options.c b/lib/dpkg/options.c
index 7cea001..2ff7795 100644
--- a/lib/dpkg/options.c
+++ b/lib/dpkg/options.c
@@ -198,7 +198,8 @@ loadcfgfile(const char *prog, const struct cmdinfo
*cmdinfos)
myfileopt(file, cmdinfos);
free(file);
- if ((home = getenv("HOME")) != NULL) {
+ home = getenv("HOME");
+ if (home != NULL) {
m_asprintf(&file, "%s/.%s.cfg", home, prog);
myfileopt(file, cmdinfos);
free(file);
diff --git a/src/filesdb.c b/src/filesdb.c
index 41f705d..df46fa6 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -304,7 +304,8 @@ ensure_packagefiles_available(struct pkginfo *pkg)
while (thisline < loaded_list_end) {
struct filenamenode *namenode;
- if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline)))
+ ptr = memchr(thisline, '\n', loaded_list_end - thisline);
+ if (ptr == NULL)
ohshit(_("files list file for package '%.250s' is missing final
newline"),
pkg_name(pkg, pnaw_nonambig));
/* Where to start next time around. */
diff --git a/src/main.c b/src/main.c
index c22cad6..bc8c714 100644
--- a/src/main.c
+++ b/src/main.c
@@ -735,7 +735,8 @@ commandfd(const char *const *argv)
infd = strtol(pipein, &endptr, 10);
if (pipein == endptr || *endptr || infd < 0 || infd > INT_MAX || errno != 0)
ohshit(_("invalid integer for --%s: `%.250s'"), cipaction->olong, pipein);
- if ((in= fdopen(infd, "r")) == NULL)
+ in = fdopen(infd, "r");
+ if (in == NULL)
ohshite(_("couldn't open `%i' for stream"), (int) infd);
for (;;) {
diff --git a/src/querycmd.c b/src/querycmd.c
index 1e5ff1f..a39ee25 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -67,14 +67,20 @@ static int getwidth(void) {
struct winsize ws;
const char *columns;
- if ((columns=getenv("COLUMNS")) && ((res=atoi(columns))>0))
- return res;
- else if (!isatty(1))
+ columns = getenv("COLUMNS");
+ if (columns) {
+ res = atoi(columns);
+ if (res > 0)
+ return res;
+ }
+
+ if (!isatty(1))
return -1;
else {
res = 80;
- if ((fd=open("/dev/tty",O_RDONLY))!=-1) {
+ fd = open("/dev/tty", O_RDONLY);
+ if (fd != -1) {
if (ioctl(fd, TIOCGWINSZ, &ws) == 0)
res = ws.ws_col;
close(fd);
diff --git a/src/statdb.c b/src/statdb.c
index 75f073c..92e9578 100644
--- a/src/statdb.c
+++ b/src/statdb.c
@@ -167,7 +167,8 @@ ensure_statoverrides(void)
while (thisline < loaded_list_end) {
fso = nfmalloc(sizeof(struct file_stat));
- if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline)))
+ ptr = memchr(thisline, '\n', loaded_list_end - thisline);
+ if (ptr == NULL)
ohshit(_("statoverride file is missing final newline"));
/* Where to start next time around. */
nextline = ptr + 1;
@@ -176,7 +177,8 @@ ensure_statoverrides(void)
*ptr = '\0';
/* Extract the uid. */
- if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
+ ptr = memchr(thisline, ' ', nextline - thisline);
+ if (ptr == NULL)
ohshit(_("syntax error in statoverride file"));
*ptr = '\0';
@@ -188,7 +190,8 @@ ensure_statoverrides(void)
ohshit(_("unexpected end of line in statoverride
file"));
/* Extract the gid */
- if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
+ ptr = memchr(thisline, ' ', nextline - thisline);
+ if (ptr == NULL)
ohshit(_("syntax error in statoverride file"));
*ptr = '\0';
@@ -200,7 +203,8 @@ ensure_statoverrides(void)
ohshit(_("unexpected end of line in statoverride
file"));
/* Extract the mode */
- if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
+ ptr = memchr(thisline, ' ', nextline - thisline);
+ if (ptr == NULL)
ohshit(_("syntax error in statoverride file"));
*ptr = '\0';
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]