[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#507952: picp: inappropriate exit status on some failure types



Package: picp
Version: 0.6.7-3
Severity: normal
Tags: patch

When picp encounters some types of errors, such as finding CTS deasserted
(implying that there is no programmer hooked up to the other end of the serial
line), it reports the error to standard error correctly, but then exits with
a zero status, indicating success.  This does not seem correct.  A patch is
attached that attempts to correct this problem, though it is a fairly quick
patch and should be reviewed more thoroughly by the maintainer before applying.
This patch also causes picp to exit with a nonzero status when receiving an
interrupt signal, and changes a strange exit(1) line in main() to more closely
conform to the error propagation style of the rest of main.c.  Apply with
[patch -p1] in the picp-0.6.7 directory.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.27.1 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages picp depends on:
ii  libc6                         2.7-16     GNU C Library: Shared libraries

picp recommends no packages.

picp suggests no packages.

-- no debconf information
diff -ur picp-0.6.7.old/main.c picp-0.6.7.new/main.c
--- picp-0.6.7.old/main.c	2008-12-05 22:40:18.000000000 -0600
+++ picp-0.6.7.new/main.c	2008-12-05 22:40:03.000000000 -0600
@@ -223,7 +223,7 @@
 {
 	fprintf(stderr, "exiting...\n");
 	ResetPICSTART();
-	exit(0);
+	exit(1);
 }
 
 //-----------------------------------------------------------------------------
@@ -3420,10 +3420,10 @@
 								fprintf(stderr, " programmer\n\n");
 								fflush(stderr);
 								CloseDevice(serialDevice);
-								exit(1);
+								fail = true;
 							}
 
-							if (DoInitPIC(picDevice))					// try to load up the parameters for this device
+							if (!fail && DoInitPIC(picDevice))					// try to load up the parameters for this device
 							{
 								while (argc && !fail)					// do as long as we can read some more
 								{
@@ -3467,6 +3467,7 @@
 													}
 
 													fprintf(stderr, " programmer does not support ISP programming\n");
+													fail = true;
 												}
 												else
 													ISPflag = true;
@@ -3499,32 +3500,49 @@
 
 											default:
 												fprintf(stderr, "bad argument: '%s'\n", *(argv - 1));	// back up, show the trouble spot
+												fail = true;
 												break;
 										}
 									}
 								}
 							}
-							else		// DoInitPIC failed
+							else if (!fail)		// DoInitPIC failed
+							{
 								fprintf(stderr, "failed to initialize %s\n", picDevice->name);
+								fail = true;
+							}
 						}
 						else
+						{
 							fprintf(stderr, "failed to obtain programmer firmware version number\n");
+							fail = true;
+						}
 					}
 					else
+					{
 						fprintf(stderr, "failed to connect to programmer\n");
+						fail = true;
+					}
 				}
 				else
+				{
 					fprintf(stderr, "failed to set up the serial port\n");
+					fail = true;
+				}
 
 				CloseDevice(serialDevice);
 			}
 			else
+			{
 				fprintf(stderr, "failed to open device '%s'\n", deviceName);
+				fail = true;
+			}
 		}
 		else
 		{
 			fprintf(stderr, "unrecognized PIC device type: '%s'\n", picName);		// don't know that one;
 			ShowDevices();														// give a helpful list of supported devices
+			fail = true;
 		}
 	}
 	else
Only in picp-0.6.7.new: main.c.~1~

Reply to: