public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH] genksyms: reduce indentation in export_symbol()
Date: Fri, 22 Nov 2024 08:22:55 +0900	[thread overview]
Message-ID: <20241121232257.1992219-1-masahiroy@kernel.org> (raw)

Modify this function to return earlier when find_symbol() returns NULL,
reducing the level of improve readability.

No functional changes are intended.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/genksyms/genksyms.c | 89 +++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 44 deletions(-)

diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index f3901c55df23..07f9b8cfb233 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -632,54 +632,55 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
 void export_symbol(const char *name)
 {
 	struct symbol *sym;
+	unsigned long crc;
+	int has_changed = 0;
 
 	sym = find_symbol(name, SYM_NORMAL, 0);
-	if (!sym)
+	if (!sym) {
 		error_with_pos("export undefined symbol %s", name);
-	else {
-		unsigned long crc;
-		int has_changed = 0;
-
-		if (flag_dump_defs)
-			fprintf(debugfile, "Export %s == <", name);
-
-		expansion_trail = (struct symbol *)-1L;
-
-		sym->expansion_trail = expansion_trail;
-		expansion_trail = sym;
-		crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff;
-
-		sym = expansion_trail;
-		while (sym != (struct symbol *)-1L) {
-			struct symbol *n = sym->expansion_trail;
-
-			if (sym->status != STATUS_UNCHANGED) {
-				if (!has_changed) {
-					print_location();
-					fprintf(stderr, "%s: %s: modversion "
-						"changed because of changes "
-						"in ", flag_preserve ? "error" :
-						       "warning", name);
-				} else
-					fprintf(stderr, ", ");
-				print_type_name(sym->type, sym->name);
-				if (sym->status == STATUS_DEFINED)
-					fprintf(stderr, " (became defined)");
-				has_changed = 1;
-				if (flag_preserve)
-					errors++;
-			}
-			sym->expansion_trail = 0;
-			sym = n;
-		}
-		if (has_changed)
-			fprintf(stderr, "\n");
-
-		if (flag_dump_defs)
-			fputs(">\n", debugfile);
-
-		printf("#SYMVER %s 0x%08lx\n", name, crc);
+		return;
 	}
+
+	if (flag_dump_defs)
+		fprintf(debugfile, "Export %s == <", name);
+
+	expansion_trail = (struct symbol *)-1L;
+
+	sym->expansion_trail = expansion_trail;
+	expansion_trail = sym;
+	crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff;
+
+	sym = expansion_trail;
+	while (sym != (struct symbol *)-1L) {
+		struct symbol *n = sym->expansion_trail;
+
+		if (sym->status != STATUS_UNCHANGED) {
+			if (!has_changed) {
+				print_location();
+				fprintf(stderr,
+					"%s: %s: modversion changed because of changes in ",
+					flag_preserve ? "error" : "warning",
+					name);
+			} else {
+				fprintf(stderr, ", ");
+			}
+			print_type_name(sym->type, sym->name);
+			if (sym->status == STATUS_DEFINED)
+				fprintf(stderr, " (became defined)");
+			has_changed = 1;
+			if (flag_preserve)
+				errors++;
+		}
+		sym->expansion_trail = 0;
+		sym = n;
+	}
+	if (has_changed)
+		fprintf(stderr, "\n");
+
+	if (flag_dump_defs)
+		fputs(">\n", debugfile);
+
+	printf("#SYMVER %s 0x%08lx\n", name, crc);
 }
 
 /*----------------------------------------------------------------------*/
-- 
2.43.0


                 reply	other threads:[~2024-11-21 23:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241121232257.1992219-1-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox