On 15/10/14 15:23, Christopher Li wrote: > On Sun, Oct 12, 2014 at 3:57 AM, Ramsay Jones > <ramsay@xxxxxxxxxxxxxxxxxxx> wrote: >> >> >> - system ($check) == 0 or die; >> + system ($check) == 0 or exit 1; > > Why not exit with the error code from sparse here? > Sparse might exit with other error code than "1" in the future. The meaning of the return value from system() is not portable. If you read the perl documentation (e.g. perldoc -f system and perldoc perlport [look for system() specific comments near the end]), you will see that there is some variability. (This is particularly true if it executes a shell to run the command). However, I have found over the years that the situation is much worse than even the perl documentation claims! (e.g. On 'platforms' like cygwin/MinGW/Win32-gnu/Win32-ActiveState and even some unix systems). About the only thing they all agree on is that a 0 return means success. So, that is all I rely on, in general. This is helped by the fact that most programs return either 0 or 1. For those programs that do return multiple failure codes, I often don't care why it failed - just that it did. In the very few cases that I do care, then I do a 'best effort' knowing that it may return the wrong code on some platforms. Hmm, off the top of my head, something like: sub exit_code { my ($code) = @_; if ($code == -1) { # failed to execute $code = 1; } elsif ($code & 127) { # died with a signal (maybe) $code = 1; } elsif ($code != 0) { # non-zero exit code (maybe) my $t = ($code >> 8) & 0xff; $code = 1; if ($t > 0) { $code = $t; } } return $code; } system ($check) or exit exit_code($?); However, I think the above is way overkill in this case. ;-) ATB, Ramsay Jones -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html