summaryrefslogtreecommitdiffstats
path: root/call
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-07-28 14:26:57 +0200
committerRalf Baechle <ralf@linux-mips.org>2017-08-03 03:46:12 +0200
commitd08f3360f435f17590416857a95fa9ccfe19204c (patch)
tree0a3434ba7d43bd3d4be7081377f147da400268f1 /call
parentb541f5ddd8936a1f2fa69d1917d6812139da0c4e (diff)
treewide: Kill assignments in if conditions.
Somewhat hard to read and the code base already has many overlong lines Found with below spatch files: @parens@ expression E, F, G; binary operator X; statement S; @@ - if ((E = F) X G) + E = F; + if (E X G) S Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'call')
-rw-r--r--call/call.c76
-rw-r--r--call/yapp.c60
2 files changed, 75 insertions, 61 deletions
diff --git a/call/call.c b/call/call.c
index 4c49cd4..e0fc054 100644
--- a/call/call.c
+++ b/call/call.c
@@ -579,7 +579,8 @@ static int nr_convert_call(char *address, struct full_sockaddr_ax25 *addr)
for (call = address; *call != '\0'; call++)
*call = toupper(*call);
- if ((fp = fopen(PROC_NR_NODES_FILE, "r")) == NULL) {
+ fp = fopen(PROC_NR_NODES_FILE, "r");
+ if (fp == NULL) {
fprintf(stderr,
"call: NET/ROM not included in the kernel\n");
return -1;
@@ -624,7 +625,8 @@ static int connect_to(char *address[])
"call: too few arguments for Rose\n");
return -1;
}
- if ((fd = socket(AF_ROSE, SOCK_SEQPACKET, 0)) < 0) {
+ fd = socket(AF_ROSE, SOCK_SEQPACKET, 0);
+ if (fd < 0) {
perror("socket");
return -1;
}
@@ -636,7 +638,8 @@ static int connect_to(char *address[])
"call: too few arguments for NET/ROM\n");
return -1;
}
- if ((fd = socket(AF_NETROM, SOCK_SEQPACKET, 0)) < 0) {
+ fd = socket(AF_NETROM, SOCK_SEQPACKET, 0);
+ if (fd < 0) {
perror("socket");
return -1;
}
@@ -651,7 +654,8 @@ static int connect_to(char *address[])
"call: too few arguments for AX.25\n");
return -1;
}
- if ((fd = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
+ fd = socket(AF_AX25, SOCK_SEQPACKET, 0);
+ if (fd < 0) {
perror("socket");
return -1;
}
@@ -1017,8 +1021,8 @@ static int start_ab_download(int mode, WINDOW ** swin, wint * wintab,
dupdstatw(*swin, "Bytes to receive: ", TRUE);
- if ((gp->dwn_file =
- open(gp->file_name, O_RDWR | O_CREAT, 0666)) == -1) {
+ gp->dwn_file = open(gp->file_name, O_RDWR | O_CREAT, 0666);
+ if (gp->dwn_file == -1) {
snprintf(s, sizeof(s), "Unable to open %s", gp->file_name);
statline(mode, s);
if (write(fd, "#ABORT#\r", 8) == -1) {
@@ -1168,7 +1172,8 @@ static int start_screen(char *call[])
for (p = idString; *p; p++)
if (islower(*p)) *p = toupper(*p);
- if ((win = initscr()) == NULL)
+ win = initscr();
+ if (win == NULL)
return -1;
attron(A_REVERSE);
@@ -1509,7 +1514,8 @@ static int readoutg(t_win * win_out, wint * wintab, menuitem * top, char buf[],
c = (wchar_t) ci;
if (c == keyesc) {
- if ((value = top_menu(wintab, top, 1)) == 0) {
+ value = top_menu(wintab, top, 1);
+ if (value == 0) {
restorecursor(mode, win_out);
return 0;
}
@@ -1854,9 +1860,9 @@ static int searche_key_words(char buf[], int *bytes, char *parms, int *parmsbyte
t = -1;
while (*pkey_words[command] != '\0') {
- if ((t =
- compstr(pkey_words[command], &buf[cnt],
- *bytes - cnt)) != -1)
+ t = compstr(pkey_words[command], &buf[cnt],
+ *bytes - cnt);
+ if (t != -1)
break;
command++;
}
@@ -2090,7 +2096,8 @@ static int cmd_call(char *call[], int mode, int encoding)
gp.dwn_cnt = 0;
wintab.next = NULL;
- if ((fd = connect_to(call)) == -1)
+ fd = connect_to(call);
+ if (fd == -1)
return FALSE;
interrupted = FALSE;
@@ -2275,17 +2282,16 @@ static int cmd_call(char *call[], int mode, int encoding)
break;
case 2:
{
- if ((sevenplcnt =
- sevenplname(mode,
- &swin,
- &wintab,
- &downloadfile,
- &logfile,
- parms,
- parmsbytes,
- buf,
- bytes)) !=
- -1)
+ sevenplcnt = sevenplname(mode,
+ &swin,
+ &wintab,
+ &downloadfile,
+ &logfile,
+ parms,
+ parmsbytes,
+ buf,
+ bytes);
+ if (sevenplcnt != -1)
sevenplus = TRUE;
}
break;
@@ -2371,14 +2377,12 @@ static int cmd_call(char *call[], int mode, int encoding)
if (buf[2] != '\0'
&& buf[2] != '\n') {
c = buf + 2;
- if ((t =
- strchr(c,
- '\n')) != NULL)
+ t = strchr(c, '\n');
+ if (t != NULL)
*t = '\0';
} else {
- if ((c =
- getenv("SHELL")) ==
- NULL)
+ c = getenv("SHELL");
+ if (c == NULL)
c = "/bin/sh";
}
@@ -2453,8 +2457,8 @@ static int cmd_call(char *call[], int mode, int encoding)
restorecursor(mode, &win_out);
continue;
}
- if ((t =
- strchr(buf, '\n')) != NULL)
+ t = strchr(buf, '\n');
+ if (t != NULL)
*t = '\0';
t = buf + 2;
while (*t != '\0' && isspace(*t))
@@ -2581,8 +2585,8 @@ static int cmd_call(char *call[], int mode, int encoding)
continue;
case 'O':
case 'o':
- if ((t =
- strchr(buf, '\n')) != NULL)
+ t = strchr(buf, '\n');
+ if (t != NULL)
*t = '\0';
if (logfile != -1) {
close(logfile);
@@ -2873,7 +2877,8 @@ int main(int argc, char **argv)
ax25mode = *optarg == 'e';
break;
case 'p':
- if ((paclen = atoi(optarg)) == 0) {
+ paclen = atoi(optarg);
+ if (paclen == 0) {
fprintf(stderr,
"call: option '-p' requires a numeric argument\n");
return 1;
@@ -2920,7 +2925,8 @@ int main(int argc, char **argv)
printf("call: %s\n", VERSION);
return 0;
case 'w':
- if ((window = atoi(optarg)) == 0) {
+ window = atoi(optarg);
+ if (window == 0) {
fprintf(stderr,
"call: option '-w' requires a numeric argument\n");
return 1;
diff --git a/call/yapp.c b/call/yapp.c
index 355701f..3be80a8 100644
--- a/call/yapp.c
+++ b/call/yapp.c
@@ -136,7 +136,8 @@ static void Send_NR(char *reason)
char buffer[257];
int length;
- if ((length = strlen(reason)) > 255)
+ length = strlen(reason);
+ if (length > 255)
length = 255;
buffer[0] = NAK;
@@ -181,7 +182,8 @@ static void Send_CN(char *reason)
char buffer[257];
int length;
- if ((length = strlen(reason)) > 255)
+ length = strlen(reason);
+ if (length > 255)
length = 255;
buffer[0] = CAN;
@@ -292,7 +294,8 @@ static int yapp_download_data(int *filefd, unsigned char *buffer)
if (buffer[0] == SOH) {
/* Parse header: 3 fields == YAPP C */
unsigned char *hptr, *hfield[3];
- if ((length = buffer[1]) == 0)
+ length = buffer[1];
+ if (length == 0)
length = 256;
hptr = buffer + 2;
while (length > 0) {
@@ -311,10 +314,10 @@ static int yapp_download_data(int *filefd, unsigned char *buffer)
}
if (*filefd == -1) {
- if ((*filefd =
- open((char *)hfield[0],
- O_RDWR | O_APPEND | O_CREAT,
- 0666)) == -1) {
+ *filefd = open((char *)hfield[0],
+ O_RDWR | O_APPEND | O_CREAT,
+ 0666);
+ if (*filefd == -1) {
printf("\n[Unable to open %s]\n",
hfield[0]);
Send_NR("Invalid filename");
@@ -357,7 +360,8 @@ static int yapp_download_data(int *filefd, unsigned char *buffer)
case STATE_RD:
if (buffer[0] == STX) {
- if ((length = buffer[1]) == 0)
+ length = buffer[1];
+ if (length == 0)
length = 256;
total += length;
sprintf(Message, "RcvData %5d bytes received",
@@ -449,7 +453,8 @@ static void yapp_download(int filefd)
}
if (FD_ISSET(fd, &sock_read)) {
- if ((length = read(fd, buffer + buflen, 511)) > 0) {
+ length = read(fd, buffer + buflen, 511);
+ if (length > 0) {
buflen += length;
do {
@@ -471,8 +476,8 @@ static void yapp_download(int filefd)
}
break;
default:
- if ((length =
- buffer[1]) == 0)
+ length = buffer[1];
+ if (length == 0)
length = 256;
if (buffer[0] == STX)
length += yappc;
@@ -678,9 +683,8 @@ static void yapp_upload(int filefd, char *filename, long filelength)
if (FD_ISSET(fd, &sock_write)) { /* Writable, only STATE_SD */
if (outlen > 0) {
- if ((n =
- write(fd, outbuffer + outbufptr,
- outlen)) > 0) {
+ n = write(fd, outbuffer + outbufptr, outlen);
+ if (n > 0) {
outbufptr += n;
outlen -= n;
total += n;
@@ -715,7 +719,8 @@ static void yapp_upload(int filefd, char *filename, long filelength)
}
if (FD_ISSET(fd, &sock_read)) {
- if ((length = read(fd, buffer + buflen, 511)) > 0) {
+ length = read(fd, buffer + buflen, 511);
+ if (length > 0) {
buflen += length;
do {
@@ -737,8 +742,8 @@ static void yapp_upload(int filefd, char *filename, long filelength)
}
break;
default:
- if ((length =
- buffer[1]) == 0)
+ length = buffer[1];
+ if (length == 0)
length = 256;
if (buflen >= (length + 2)) {
if (!yapp_upload_data(filefd, filename, filelength, buffer))
@@ -772,7 +777,8 @@ void cmd_yapp(char *buf, int bytes)
switch (buf[0]) {
case 'U':
case 'u':
- if ((t = strchr(buf, '\n')) != NULL)
+ t = strchr(buf, '\n');
+ if (t != NULL)
*t = '\0';
t = buf + 2;
while (*t != '\0' && isspace(*t))
@@ -783,7 +789,8 @@ void cmd_yapp(char *buf, int bytes)
Send_NR("No filename");
return;
}
- if ((filefd = open(t, O_RDONLY)) == -1) {
+ filefd = open(t, O_RDONLY);
+ if (filefd == -1) {
printf("\n[Unable to open upload file]\n");
Send_NR("Invalid filename");
return;
@@ -805,19 +812,20 @@ void cmd_yapp(char *buf, int bytes)
case 'D':
case 'd':
- if ((t = strchr(buf, '\n')) != NULL)
+ t = strchr(buf, '\n');
+ if (t != NULL)
*t = '\0';
t = buf + 2;
while (*t != '\0' && isspace(*t))
t++;
if (*t == '\0')
filefd = -1;
- else if ((filefd =
- open(t, O_RDWR | O_APPEND | O_CREAT,
- 0666)) == -1) {
- printf("\n[Unable to open %s]\n", buf + 2);
- Send_NR("Invalid filename");
- return;
+ else {filefd = open(t, O_RDWR | O_APPEND | O_CREAT, 0666);
+ if (filefd == -1) {
+ printf("\n[Unable to open %s]\n", buf + 2);
+ Send_NR("Invalid filename");
+ return;
+ }
}
printf("\n[Downloading using YAPP]\n");
yapp_download(filefd);