diff options
Diffstat (limited to 'rose/rsattach.c')
-rw-r--r-- | rose/rsattach.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/rose/rsattach.c b/rose/rsattach.c index f91935e..2afdc67 100644 --- a/rose/rsattach.c +++ b/rose/rsattach.c @@ -38,7 +38,8 @@ static int readconfig(char *port) char buffer[90], *s; int n = 0; - if ((fp = fopen(CONF_RSPORTS_FILE, "r")) == NULL) { + fp = fopen(CONF_RSPORTS_FILE, "r"); + if (fp == NULL) { fprintf(stderr, "rsattach: cannot open rsports file\n"); return FALSE; } @@ -46,13 +47,15 @@ static int readconfig(char *port) while (fgets(buffer, 90, fp) != NULL) { n++; - if ((s = strchr(buffer, '\n')) != NULL) + s = strchr(buffer, '\n'); + if (s != NULL) *s = '\0'; if (strlen(buffer) > 0 && *buffer == '#') continue; - if ((s = strtok(buffer, " \t\r\n")) == NULL) { + s = strtok(buffer, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "rsattach: unable to parse line %d of the rsports file\n", n); return FALSE; } @@ -60,7 +63,8 @@ static int readconfig(char *port) if (strcmp(s, port) != 0) continue; - if ((s = strtok(NULL, " \t\r\n")) == NULL) { + s = strtok(NULL, " \t\r\n"); + if (s == NULL) { fprintf(stderr, "rsattach: unable to parse line %d of the rsports file\n", n); return FALSE; } @@ -85,7 +89,8 @@ static int getfreedev(char *dev) int fd; int i; - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { perror("rsattach: socket"); return FALSE; } @@ -116,7 +121,8 @@ static int startiface(char *dev, struct hostent *hp) char addr[5]; int fd; - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { perror("rsattach: socket"); return FALSE; } @@ -187,7 +193,8 @@ int main(int argc, char *argv[]) while ((fd = getopt(argc, argv, "i:m:v")) != -1) { switch (fd) { case 'i': - if ((hp = gethostbyname(optarg)) == NULL) { + hp = gethostbyname(optarg); + if (hp == NULL) { fprintf(stderr, "rsattach: invalid internet name/address - %s\n", optarg); return 1; } |