linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] initramfs: move unnecessary memcmp from hot path
@ 2021-09-22 11:52 David Disseldorp
  2021-09-22 11:52 ` [PATCH 2/5] initramfs: print helpful cpio error on "crc" magic David Disseldorp
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: David Disseldorp @ 2021-09-22 11:52 UTC (permalink / raw)
  To: linux-fsdevel, linux-doc; +Cc: viro, willy, David Disseldorp

do_header() is called for each cpio entry and first checks for "newc"
magic before parsing further. The magic check includes a special case
error message if POSIX.1 ASCII (cpio -H odc) magic is detected. This
special case POSIX.1 check needn't be done in the hot path, so move it
under the non-newc-magic error path.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 init/initramfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index af27abc59643..f01590cefa2d 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -256,12 +256,11 @@ static int __init do_collect(void)
 
 static int __init do_header(void)
 {
-	if (memcmp(collected, "070707", 6)==0) {
-		error("incorrect cpio method used: use -H newc option");
-		return 1;
-	}
 	if (memcmp(collected, "070701", 6)) {
-		error("no cpio magic");
+		if (memcmp(collected, "070707", 6) == 0)
+			error("incorrect cpio method used: use -H newc option");
+		else
+			error("no cpio magic");
 		return 1;
 	}
 	parse_header(collected);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-09-23  7:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 11:52 [PATCH 1/5] initramfs: move unnecessary memcmp from hot path David Disseldorp
2021-09-22 11:52 ` [PATCH 2/5] initramfs: print helpful cpio error on "crc" magic David Disseldorp
2021-09-22 11:52 ` [PATCH v2 3/5] docs: remove mention of "crc" cpio format support David Disseldorp
2021-09-22 11:52 ` [PATCH 4/5] initramfs: use do_utime() wrapper consistently David Disseldorp
2021-09-22 11:52 ` [PATCH 5/5] initramfs: add INITRAMFS_PRESERVE_MTIME Kconfig option David Disseldorp
2021-09-22 23:28 ` [PATCH 1/5] initramfs: move unnecessary memcmp from hot path Chaitanya Kulkarni
2021-09-23  7:43   ` David Disseldorp
2021-09-22 23:35 ` Al Viro
2021-09-22 23:51   ` Chaitanya Kulkarni
2021-09-23  7:33   ` David Disseldorp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).