#1 Temporary fix for bug #797122

open
nobody
None
5
2012-09-14
2003-08-29
Vadim Tkachenko
No

Root cause is not checking the return status of COM_open.

Ideally, COM_open should just blow up in case something
goes wrong, 'cause it doesn't really make sense to
continue if we can't open the serial port... IMHO.

--- main.c.orig 2003-08-29 00:03:33.000000000 -0700
+++ main.c 2003-08-29 00:04:55.000000000 -0700
@@ -162,7 +162,10 @@
debugmode = 1 ;
break;
case 'd':
- COM_open( optarg ) ;
+ if ( COM_open( optarg ) ) {
+ fprintf(stderr, "Can't open serial
port, see system log\n");
+ ow_exit(1);
+ }
break ;
default:
fprintf(stderr, "invalid option: %c, try
-h for help\n", o);

Another one (slightly improving the diagnostics):

--- ow_com.c.orig 2003-08-28 23:37:07.000000000 -0700
+++ ow_com.c 2003-08-29 00:08:02.000000000 -0700
@@ -34,7 +34,11 @@
} else if ( (devport = (char *)
malloc(strlen(pn)+1)) ) {
strcpy( devport , pn ) ;
if ((devfd = open(devport, O_RDWR |
O_NONBLOCK)) < 0) {
- syslog( LOG_ERR,"Cannot open port: %s
error=%d\n",devport,errno) ;
+
+ // VT: FIXME: What's the point of
continuing to do anything at
+ // all if we've failed to open the serial
port?
+
+ syslog( LOG_ERR,"Cannot open %s
(%s)\n",devport,strerror(errno)) ;
return 1;
}
tcgetattr(devfd, &oldSerialTio);

Discussion


Anonymous


Cancel   Add attachments