Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 179ec3e5 authored by Colin Cross's avatar Colin Cross
Browse files

Fix errors caught by go vet in compliance package

`go test` implicitly runs `go vet` and fails the tests if vet
errors are found.  Fix all the issues found by vet.

Test: go test build/make/tools/compliance/...
Change-Id: If0684cf124ece4931af440008cd44a61c22de475
parent 35f79c37
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -69,12 +69,12 @@ func main() {
	} else {
		dir, err := filepath.Abs(filepath.Dir(*outputFile))
		if err != nil {
			fmt.Fprintf(os.Stderr, "cannot determine path to %q: %w\n", *outputFile, err)
			fmt.Fprintf(os.Stderr, "cannot determine path to %q: %s\n", *outputFile, err)
			os.Exit(1)
		}
		fi, err := os.Stat(dir)
		if err != nil {
			fmt.Fprintf(os.Stderr, "cannot read directory %q of %q: %w\n", dir, *outputFile, err)
			fmt.Fprintf(os.Stderr, "cannot read directory %q of %q: %s\n", dir, *outputFile, err)
			os.Exit(1)
		}
		if !fi.IsDir() {
@@ -102,7 +102,7 @@ func main() {
	if *outputFile != "-" {
		err := os.WriteFile(*outputFile, ofile.(*bytes.Buffer).Bytes(), 0666)
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not write output to %q: %w\n", *outputFile, err)
			fmt.Fprintf(os.Stderr, "could not write output to %q: %s\n", *outputFile, err)
			os.Exit(1)
		}
	}
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ func Test(t *testing.T) {

			err := billOfMaterials(&ctx, rootFiles...)
			if err != nil {
				t.Fatalf("bom: error = %w, stderr = %v", err, stderr)
				t.Fatalf("bom: error = %v, stderr = %v", err, stderr)
				return
			}
			if stderr.Len() > 0 {
+1 −1
Original line number Diff line number Diff line
@@ -1217,7 +1217,7 @@ func Test_graphviz(t *testing.T) {
			outList := strings.Split(stdout.String(), "\n")
			outLine := 0
			if outList[outLine] != "strict digraph {" {
				t.Errorf("dumpgraph: got 1st line %v, want strict digraph {")
				t.Errorf("dumpgraph: got 1st line %v, want strict digraph {", outList[outLine])
			}
			outLine++
			if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
+1 −1
Original line number Diff line number Diff line
@@ -3305,7 +3305,7 @@ func Test_graphviz(t *testing.T) {
			outList := strings.Split(stdout.String(), "\n")
			outLine := 0
			if outList[outLine] != "strict digraph {" {
				t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {")
				t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {", outList[outLine])
			}
			outLine++
			if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
+5 −5
Original line number Diff line number Diff line
@@ -74,12 +74,12 @@ func main() {
	} else {
		dir, err := filepath.Abs(filepath.Dir(*outputFile))
		if err != nil {
			fmt.Fprintf(os.Stderr, "cannot determine path to %q: %w\n", *outputFile, err)
			fmt.Fprintf(os.Stderr, "cannot determine path to %q: %s\n", *outputFile, err)
			os.Exit(1)
		}
		fi, err := os.Stat(dir)
		if err != nil {
			fmt.Fprintf(os.Stderr, "cannot read directory %q of %q: %w\n", dir, *outputFile, err)
			fmt.Fprintf(os.Stderr, "cannot read directory %q of %q: %s\n", dir, *outputFile, err)
			os.Exit(1)
		}
		if !fi.IsDir() {
@@ -107,7 +107,7 @@ func main() {
	if *outputFile != "-" {
		err := os.WriteFile(*outputFile, ofile.(*bytes.Buffer).Bytes(), 0666)
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not write output to %q: %w\n", *outputFile, err)
			fmt.Fprintf(os.Stderr, "could not write output to %q: %s\n", *outputFile, err)
			os.Exit(1)
		}
	}
@@ -139,13 +139,13 @@ func htmlNotice(ctx *context, files ...string) error {
	}

	fmt.Fprintln(ctx.stdout, "<!DOCTYPE html>")
	fmt.Fprintln(ctx.stdout, "<html><head>\n")
	fmt.Fprintln(ctx.stdout, "<html><head>")
	fmt.Fprintln(ctx.stdout, "<style type=\"text/css\">")
	fmt.Fprintln(ctx.stdout, "body { padding: 2px; margin: 0; }")
	fmt.Fprintln(ctx.stdout, "ul { list-style-type: none; margin: 0; padding: 0; }")
	fmt.Fprintln(ctx.stdout, "li { padding-left: 1em; }")
	fmt.Fprintln(ctx.stdout, ".file-list { margin-left: 1em; }")
	fmt.Fprintln(ctx.stdout, "</style>\n")
	fmt.Fprintln(ctx.stdout, "</style>")
	if 0 < len(ctx.title) {
		fmt.Fprintf(ctx.stdout, "<title>%s</title>\n", html.EscapeString(ctx.title))
	}
Loading