summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/devfsd.c37
-rw-r--r--miscutils/hdparm.c3
-rw-r--r--miscutils/readahead.c10
3 files changed, 30 insertions, 20 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index cd94869..9990142 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -465,7 +465,8 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask
free(p);
return;
}
- if ((fp = fopen(path, "r")) != NULL) {
+ fp = fopen(path, "r");
+ if (fp != NULL) {
while (fgets(buf, STRING_LENGTH, fp) != NULL) {
/* Skip whitespace */
line = buf;
@@ -560,7 +561,8 @@ static void process_config_line(const char *line, unsigned long *event_mask)
case 4: /* "PERMISSIONS" */
new->action.what = AC_PERMISSIONS;
/* Get user and group */
- if ((ptr = strchr(p[0], '.')) == NULL) {
+ ptr = strchr(p[0], '.');
+ if (ptr == NULL) {
msg = "UID.GID";
goto process_config_line_err; /*"missing '.' in UID.GID"*/
}
@@ -979,8 +981,9 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
/* Same type */
if (S_ISLNK(source_stat->st_mode)) {
- if ((source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1)) < 0
- || (dest_len = readlink(destpath , dest_link , STRING_LENGTH - 1)) < 0
+ source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1);
+ if ((source_len < 0)
+ || (dest_len = readlink(destpath, dest_link, STRING_LENGTH - 1)) < 0
)
return FALSE;
source_link[source_len] = '\0';
@@ -999,7 +1002,8 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
unlink(destpath);
switch (source_stat->st_mode & S_IFMT) {
case S_IFSOCK:
- if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0)
break;
un_addr.sun_family = AF_UNIX;
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
@@ -1009,14 +1013,16 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
break;
goto do_chown;
case S_IFLNK:
- if ((val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1)) < 0)
+ val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1);
+ if (val < 0)
break;
symlink_val[val] = '\0';
if (symlink(symlink_val, destpath) == 0)
return TRUE;
break;
case S_IFREG:
- if ((fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT)) < 0)
+ fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT);
+ if (fd < 0)
break;
close(fd);
if (chmod(destpath, new_mode & ~S_IFMT) != 0)
@@ -1082,7 +1088,7 @@ static int get_uid_gid(int flag, const char *string)
if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
return atoi(string);
- if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
+ if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
return pw_ent->pw_uid;
if (flag == GID && (grp_ent = getgrnam(string)) != NULL)
@@ -1197,7 +1203,8 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
struct dirent *de;
char *path;
- if ((dp = warn_opendir(dir_name)) == NULL)
+ dp = warn_opendir(dir_name);
+ if (dp == NULL)
return;
while ((de = readdir(dp)) != NULL) {
@@ -1581,7 +1588,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
ch = input[1];
if (isspace(ch) ||(ch == '/') ||(ch == '\0')) {
/* User's own home directory: leave separator for next time */
- if ((env = getenv("HOME")) == NULL) {
+ env = getenv("HOME");
+ if (env == NULL) {
info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
return FALSE;
}
@@ -1600,7 +1608,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
goto st_expr_expand_out;
safe_memcpy(tmp, input, len);
input = ptr - 1;
- if ((pwent = getpwnam(tmp)) == NULL) {
+ pwent = getpwnam(tmp);
+ if (pwent == NULL) {
info_logger(LOG_INFO, "no pwent for: %s", tmp);
return FALSE;
}
@@ -1680,7 +1689,8 @@ static const char *expand_variable(char *buffer, unsigned int length,
safe_memcpy(tmp, input, len);
input = ptr - 1;
- if ((env = get_variable_v2(tmp, func, info)) == NULL) {
+ env = get_variable_v2(tmp, func, info);
+ if (env == NULL) {
info_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
return NULL;
}
@@ -1740,7 +1750,8 @@ static const char *expand_variable(char *buffer, unsigned int length,
}
--ptr;
/* At this point ptr should point to closing brace of "${var:-word}" */
- if ((env = get_variable_v2(tmp, func, info)) != NULL) {
+ env = get_variable_v2(tmp, func, info);
+ if (env != NULL) {
/* Found environment variable, so skip the input to the closing brace
and return the variable */
input = ptr;
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 93b1aac..03a30e6 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -1111,7 +1111,8 @@ static void identify(uint16_t *val)
/* reset result */
jj = val[HWRST_RSLT];
if ((jj & VALID) == VALID_VAL) {
- if (!(oo = (jj & RST0)))
+ oo = (jj & RST0);
+ if (!oo)
jj >>= 8;
if ((jj & DEV_DET) == JUMPER_VAL)
strng = " determined by the jumper";
diff --git a/miscutils/readahead.c b/miscutils/readahead.c
index 647eb31..7b375cf 100644
--- a/miscutils/readahead.c
+++ b/miscutils/readahead.c
@@ -15,17 +15,15 @@
int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int readahead_main(int argc, char **argv)
{
- FILE *f;
int retval = EXIT_SUCCESS;
if (argc == 1) bb_show_usage();
while (*++argv) {
- if ((f = fopen_or_warn(*argv, "r")) != NULL) {
- int r, fd=fileno(f);
-
- r = readahead(fd, 0, fdlength(fd));
- fclose(f);
+ int fd = open_or_warn(*argv, O_RDONLY);
+ if (fd >= 0) {
+ int r = readahead(fd, 0, fdlength(fd));
+ close(fd);
if (r >= 0) continue;
}
retval = EXIT_FAILURE;