File setserial-2.17-error.diff of Package setserial
--- setserial.c
+++ setserial.c
@@ -412,7 +412,7 @@
}
#endif
-void get_serial(char *device)
+int get_serial(char *device)
{
struct serial_struct serinfo;
int fd;
@@ -420,13 +420,13 @@
if ((fd = open(device, O_RDWR|O_NONBLOCK)) < 0) {
perror(device);
- return;
+ return 1;
}
serinfo.reserved_char[0] = 0;
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0) {
perror("Cannot get serial info");
close(fd);
- return;
+ return 1;
}
if (serinfo.irq == 9)
serinfo.irq = 2; /* People understand 2 better than 9 */
@@ -472,16 +472,18 @@
printf("\n");
}
close(fd);
+
+ return 0;
}
-void set_serial(char *device, char ** arg)
+int set_serial(char *device, char ** arg)
{
struct serial_struct old_serinfo, new_serinfo;
struct flag_type_table *p;
int fd;
int do_invert = 0;
char *word;
-
+ int e = 0;
if ((fd = open(device, O_RDWR|O_NONBLOCK)) < 0) {
if (verbosity==0 && errno==ENOENT)
@@ -614,7 +616,9 @@
}
close(fd);
if (verbose_flag)
- get_serial(device);
+ e = get_serial(device);
+
+ return e;
}
void do_wild_intr(char *device)
@@ -718,6 +722,7 @@
{
int get_flag = 0, wild_intr_flag = 0;
int c;
+ int e = 0;
extern int optind;
extern char *optarg;
@@ -760,8 +765,8 @@
if (get_flag) {
argv += optind;
while (*argv)
- get_serial(*argv++);
- exit(0);
+ e |= get_serial(*argv++);
+ exit(e);
}
if (argc == optind)
usage();
@@ -770,9 +775,9 @@
exit(0);
}
if (argc-optind == 1)
- get_serial(argv[optind]);
+ e = get_serial(argv[optind]);
else
- set_serial(argv[optind], argv+optind+1);
- exit(0);
+ e = set_serial(argv[optind], argv+optind+1);
+ exit(e);
}