Blob Blame History Raw
From: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon, 1 Jun 2020 14:57:21 +0900
Subject: modpost: remove get_next_text() and make {grab,release_}file static
Was-Git-commit: 75893572d45399cefbb88443d0878adae9cb0b41
Was-Patch-mainline: v5.8-rc1
Patch-mainline: Never, this revert is SUSE-specific
References: required by patches.suse/add-suse-supported-flag.patch

get_next_line() is no longer used. Remove.

grab_file() and release_file() are only used in modpost.c. Make them
static.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---

 scripts/mod/modpost.c |   38 ++++++++++++++++++++++++++++++++++++--
 scripts/mod/modpost.h |    3 +++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4fdf992e9729..93019349f022 100644
--- b/scripts/mod/modpost.c
+++ a/scripts/mod/modpost.c
@@ -485,6 +485,40 @@
 	return map;
 }
 
+/**
+  * Return a copy of the next line in a mmap'ed file.
+  * spaces in the beginning of the line is trimmed away.
+  * Return a pointer to a static buffer.
+  **/
+static char *get_next_line(unsigned long *pos, void *file, unsigned long size)
+{
+	static char line[4096];
+	int skip = 1;
+	size_t len = 0;
+	signed char *p = (signed char *)file + *pos;
+	char *s = line;
+
+	for (; *pos < size ; (*pos)++) {
+		if (skip && isspace(*p)) {
+			p++;
+			continue;
+		}
+		skip = 0;
+		if (*p != '\n' && (*pos < size)) {
+			len++;
+			*s++ = *p++;
+			if (len > 4095)
+				break; /* Too long, stop */
+		} else {
+			/* End of string */
+			*s = '\0';
+			return line;
+		}
+	}
+	/* End of buffer */
+	return NULL;
+}
+
 static void release_file(void *file, size_t size)
 {
 	munmap(file, size);