From 7bc7039a6a518ed43f6177763d584e354ebd4bd7 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 24 May 2024 10:07:54 +0800 Subject: [PATCH] syscall: prevent redundant newline from empty $extraimports 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 Auto-Submit: Ian Lance Taylor Reviewed-by: Carlos Amedee LUCI-TryBot-Result: Go LUCI --- src/syscall/mksyscall.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/syscall/mksyscall.pl b/src/syscall/mksyscall.pl index 47efbffcbc..b46a3f9438 100755 --- a/src/syscall/mksyscall.pl +++ b/src/syscall/mksyscall.pl @@ -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 <