Add missing return value checks

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
pull/100/head
Yegor Yefremov 2018-09-18 13:43:29 +02:00
parent 0ff988eeef
commit 1ce4dc7b39
5 changed files with 58 additions and 17 deletions

View File

@ -690,12 +690,15 @@ void writesettings(char* name){
for (i=0; i < 2048 ;i++) { for (i=0; i < 2048 ;i++) {
sprintf(buf, "<%03X>%c.", i, (is_set(i, ENABLE))?'1':'0'); sprintf(buf, "<%03X>%c.", i, (is_set(i, ENABLE))?'1':'0');
write(fd, buf, 7); if (write(fd, buf, 7) < 0)
perror("write");
for (j=0; j<8 ; j++){ for (j=0; j<8 ; j++){
sprintf(buf, "%02X", sniftab[i].notch.data[j]); sprintf(buf, "%02X", sniftab[i].notch.data[j]);
write(fd, buf, 2); if (write(fd, buf, 2) < 0)
perror("write");
} }
write(fd, "\n", 1); if (write(fd, "\n", 1) < 0)
perror("write");
/* 7 + 16 + 1 = 24 bytes per entry */ /* 7 + 16 + 1 = 24 bytes per entry */
} }
close(fd); close(fd);

3
jacd.c
View File

@ -484,7 +484,8 @@ int main(int argc, char *argv[])
break; break;
case 'p': case 'p':
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
asprintf(&program_invocation_name, "%s.%s", program_invocation_short_name, optarg); if (asprintf(&program_invocation_name, "%s.%s", program_invocation_short_name, optarg) < 0)
error(1, errno, "asprintf(program invocation name)");
#else #else
error(0, 0, "compile with -D_GNU_SOURCE to use -p"); error(0, 0, "compile with -D_GNU_SOURCE to use -p");
#endif #endif

3
jsr.c
View File

@ -210,7 +210,8 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
} else { } else {
write(STDOUT_FILENO, buf, ret); if (write(STDOUT_FILENO, buf, ret) < 0)
error(1, errno, "write(stdout)");
} }
} }
} }

View File

@ -157,25 +157,40 @@ int main(int argc, char **argv)
if (speed) { if (speed) {
sprintf(buf, "C\rS%s\r", speed); sprintf(buf, "C\rS%s\r", speed);
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (btr) { if (btr) {
sprintf(buf, "C\rs%s\r", btr); sprintf(buf, "C\rs%s\r", btr);
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (send_read_status_flags) { if (send_read_status_flags) {
sprintf(buf, "F\r"); sprintf(buf, "F\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (send_listen) { if (send_listen) {
sprintf(buf, "L\r"); sprintf(buf, "L\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} else if (send_open) { } else if (send_open) {
sprintf(buf, "O\r"); sprintf(buf, "O\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
/* set slcan line discipline on given tty */ /* set slcan line discipline on given tty */
@ -229,7 +244,10 @@ int main(int argc, char **argv)
if (send_close) { if (send_close) {
sprintf(buf, "C\r"); sprintf(buf, "C\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
} }

View File

@ -326,25 +326,40 @@ int main(int argc, char *argv[])
if (speed) { if (speed) {
sprintf(buf, "C\rS%s\r", speed); sprintf(buf, "C\rS%s\r", speed);
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (btr) { if (btr) {
sprintf(buf, "C\rs%s\r", btr); sprintf(buf, "C\rs%s\r", btr);
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (send_read_status_flags) { if (send_read_status_flags) {
sprintf(buf, "F\r"); sprintf(buf, "F\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
if (send_listen) { if (send_listen) {
sprintf(buf, "L\r"); sprintf(buf, "L\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} else if (send_open) { } else if (send_open) {
sprintf(buf, "O\r"); sprintf(buf, "O\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
/* set slcan like discipline on given tty */ /* set slcan like discipline on given tty */
@ -412,7 +427,10 @@ int main(int argc, char *argv[])
if (send_close) { if (send_close) {
sprintf(buf, "C\r"); sprintf(buf, "C\r");
write(fd, buf, strlen(buf)); if (write(fd, buf, strlen(buf)) <= 0) {
perror("write");
exit(EXIT_FAILURE);
}
} }
/* Reset old rates */ /* Reset old rates */