[svn-commits] seanbright: tools/trunk r6421 - /tools/trunk/dahdi_monitor.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Apr 21 08:45:02 CDT 2009


Author: seanbright
Date: Tue Apr 21 08:44:58 2009
New Revision: 6421

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6421
Log:
Correct error check for fopen() calls in dahdi_monitor.c.

dahdi_monitor.c was checking for an error calling fopen() by determining if the
return value was less than 0.  fopen(), however, returns a FILE * and returns
NULL on failure.

(closes issue #14894)
Reported by: gknispel_proformatique
Patches:
      dahdi_monitor_fix_check_fopen_result.patch uploaded by gknispel (license 261)

Modified:
    tools/trunk/dahdi_monitor.c

Modified: tools/trunk/dahdi_monitor.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/dahdi_monitor.c?view=diff&rev=6421&r1=6420&r2=6421
==============================================================================
--- tools/trunk/dahdi_monitor.c (original)
+++ tools/trunk/dahdi_monitor.c Tue Apr 21 08:44:58 2009
@@ -343,7 +343,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_BRX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_BRX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -359,7 +359,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -376,7 +376,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_BRX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_BRX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -393,7 +393,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -411,7 +411,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_TX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_TX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -428,7 +428,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_PRE_TX] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_PRE_TX] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -446,7 +446,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_STEREO] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_STEREO] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}
@@ -463,7 +463,7 @@
 				fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
 				exit(EXIT_FAILURE);
 			}
-			if ((ofh[MON_PRE_STEREO] = fopen(optarg, "w")) < 0) {
+			if ((ofh[MON_PRE_STEREO] = fopen(optarg, "w")) == NULL) {
 				fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
 				exit(EXIT_FAILURE);
 			}




More information about the svn-commits mailing list