]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: prevent redundant newline from empty $extraimports
authorAndy Pan <i@andypan.me>
Fri, 24 May 2024 02:07:54 +0000 (10:07 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 24 May 2024 17:15:02 +0000 (17:15 +0000)
Currently mksyscall script produces one redundant newline
when $extraimports is empty, leading to a gofmt warning
reported by "git codereview change".

Change-Id: I57b0fa040347375698973e777285deded16ab62e
Reviewed-on: https://go-review.googlesource.com/c/go/+/587877
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/syscall/mksyscall.pl

index 47efbffcbcb113140c2c63b575df17822989a6e6..b46a3f9438bd87842b066ed36c3cef6545d4d378 100755 (executable)
@@ -33,6 +33,7 @@ my $arm = 0; # 64-bit value should use (even, odd)-pair
 my $libc = 0;
 my $tags = "";  # build tags
 my $newtags = ""; # new style build tags
+my $stdimports = 'import "unsafe"';
 my $extraimports = "";
 
 if($ARGV[0] eq "-b32") {
@@ -390,6 +391,10 @@ if($errors) {
        exit 1;
 }
 
+if($extraimports ne "") {
+    $stdimports .= "\n$extraimports";
+}
+
 # TODO: this assumes tags are just simply comma separated. For now this is all the uses.
 $newtags = $tags =~ s/,/ && /r;
 
@@ -401,8 +406,7 @@ print <<EOF;
 
 package syscall
 
-import "unsafe"
-$extraimports
+$stdimports
 
 $text
 EOF