Skip to contentSkip to conversation

headers_install: check exit status of unifdef

PATCH Superseded Mike Frysinger 3 participants 5 messages Nov 23, 2010 – Dec 14, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 headers_install: check exit status of unifdef

If unifdef fails for any reason (like segfaulting), we should be aborting the install steps. So check its exit status in this unlikely scenario.

---
 scripts/headers_install.pl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/headers_install.pl +2 -1
index 4ca3be3..00856f1 100644
@@ -44,7 +44,8 @@ foreach my $file (@files) {
 	close $out;
 	close $in;
 
-	system $unifdef . " $tmpfile > $installdir/$file";
+	system $unifdef . " $tmpfile > $installdir/$file"
+	    and die "$tmpfile: $!\n";
 	unlink $tmpfile;
 }
 exit 0;
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH v2 1/1 headers_install: check exit status of unifdef

If unifdef fails for any reason (like segfaulting), we should be aborting the install steps. So check its exit status in this unlikely scenario.

---
v2
- apparently exit status of 1 is normal for unifdef, so need to handle that too

 scripts/headers_install.pl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
scripts/headers_install.pl +7 -0
index 4ca3be3..59ad768 100644
@@ -45,6 +45,13 @@ foreach my $file (@files) {
 	close $in;
 
 	system $unifdef . " $tmpfile > $installdir/$file";
+	# unifdef will exit 0 on success, and will exit 1 when the
+	# file was processed successfully but no changes were made,
+	# so abort only when it's higher than that.
+	my $e = $? >> 8;
+	if ($e > 2) {
+		die "$tmpfile: $!\n";
+	}
 	unlink $tmpfile;
 }
 exit 0;
Signature · 1 line
1.7.3.2
#2 lore raw
Quoted 18 lines · On Tue, 23 Nov 2010 17:41:36 -0500 Mike Frysinger wrote:

If unifdef fails for any reason (like segfaulting), we should be aborting the install steps. So check its exit status in this unlikely scenario.

---
v2
- apparently exit status of 1 is normal for unifdef, so need to handle that too

 scripts/headers_install.pl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
scripts/headers_install.pl +0 -0
index 4ca3be3..59ad768 100644

scripts/headers_install.pl foreach my $file (@files) { · line 52

Quoted 8 lines
scripts/headers_install.pl +5 -0
@@ -45,6 +45,13 @@ foreach my $file (@files) {
 	close $in;
 
 	system $unifdef . " $tmpfile > $installdir/$file";
+	# unifdef will exit 0 on success, and will exit 1 when the
+	# file was processed successfully but no changes were made,
+	# so abort only when it's higher than that.
+	my $e = $? >> 8;
+	if ($e > 2) {
	if ($e > 1) {

??

scripts/headers_install.pl foreach my $file (@files) { · line 57

Quoted 6 lines
scripts/headers_install.pl +2 -0
+		die "$tmpfile: $!\n";
+	}
 	unlink $tmpfile;
 }
 exit 0;

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#3 lore raw

PATCH v3 1/1 headers_install: check exit status of unifdef

In reply to Mike Frysinger

If unifdef fails for any reason (like segfaulting), we should be aborting the install steps. So check its exit status in this unlikely scenario.

---
v3
- fix thinko pointed out by Randy

 scripts/headers_install.pl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
scripts/headers_install.pl +7 -0
index 4ca3be3..efb3be1 100644
@@ -45,6 +45,13 @@ foreach my $file (@files) {
 	close $in;
 
 	system $unifdef . " $tmpfile > $installdir/$file";
+	# unifdef will exit 0 on success, and will exit 1 when the
+	# file was processed successfully but no changes were made,
+	# so abort only when it's higher than that.
+	my $e = $? >> 8;
+	if ($e > 1) {
+		die "$tmpfile: $!\n";
+	}
 	unlink $tmpfile;
 }
 exit 0;
Signature · 1 line
1.7.3.2
#4 lore raw
Quoted 11 lines · Mike Frysinger

If unifdef fails for any reason (like segfaulting), we should be aborting the install steps. So check its exit status in this unlikely scenario.

---
v3
- fix thinko pointed out by Randy

  scripts/headers_install.pl |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

Applied to kbuild-2.6#kbuild, thanks.

Michal