Skip to contentSkip to conversation

checkstack: parse architecture correctly

PATCH In review Stephen Hemminger 2 participants 2 messages Jan 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 checkstack: parse architecture correctly

The checkstack script wouldn't work because it was picking up the newline on the end of the output of uname -m.

Also, use a standard perl construct to print error message and exit with non-zero error code.

scripts/checkstack.pl +2 -2
@@ -32,6 +32,7 @@ my (@stack, $re, $x, $xs);
 	my $arch = shift;
 	if ($arch eq "") {
 		$arch = `uname -m`;
+		chomp $arch;
 	}
 
 	$x	= "[0-9a-f]";	# hex character
@@ -85,8 +86,7 @@ my (@stack, $re, $x, $xs);
 		#   0:   00 e8 38 01     LINK 0x4e0;
 		$re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
 	} else {
-		print("wrong or unknown architecture\n");
-		exit
+	    	die "wrong or unknown architecture\"$arch\"\n";
 	}
 }
 
#1 lore raw
Quoted 10 lines · Stephen Hemminger

The checkstack script wouldn't work because it was picking up the newline on the end of the output of uname -m.

Also, use a standard perl construct to print error message and exit with non-zero error code.

scripts/checkstack.pl +0 -0

[...]

scripts/checkstack.pl my (@stack, $re, $x, $xs); · line 89

Quoted 3 lines
scripts/checkstack.pl +1 -2
-		print("wrong or unknown architecture\n");
-		exit
+	    	die "wrong or unknown architecture\"$arch\"\n";

a space before the variable would be good, maybe qq() instead of "" to avoid backslashing? Also the \n is reduntant there, otherwise you will loose the file+line info.