diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-12-25 16:33:36 +0100 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2024-12-28 15:31:03 +0100 |
commit | e1352d7ead2b8803689823cd4059c1ec72609ed4 (patch) | |
tree | 061b8d24641ba9ed237c8dda90d364de606855ef /scripts | |
parent | modpost: fix the missed iteration for the max bit in do_input() (diff) | |
download | linux-e1352d7ead2b8803689823cd4059c1ec72609ed4.tar.xz linux-e1352d7ead2b8803689823cd4059c1ec72609ed4.zip |
modpost: refactor do_vmbus_entry()
Optimize the size of guid_name[], as it only requires 1 additional byte
for '\0' instead of 2.
Simplify the loop by incrementing the iterator by 1 instead of 2.
Remove the unnecessary TO_NATIVE() call, as the guid is represented as
a byte stream.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/file2alias.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index ff263c285977..2c7b76d4e8ec 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -812,15 +812,13 @@ static void do_virtio_entry(struct module *mod, void *symval) * Each byte of the guid will be represented by two hex characters * in the name. */ - static void do_vmbus_entry(struct module *mod, void *symval) { - int i; DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid); - char guid_name[(sizeof(*guid) + 1) * 2]; + char guid_name[sizeof(*guid) * 2 + 1]; - for (i = 0; i < (sizeof(*guid) * 2); i += 2) - sprintf(&guid_name[i], "%02x", TO_NATIVE((guid->b)[i/2])); + for (int i = 0; i < sizeof(*guid); i++) + sprintf(&guid_name[i * 2], "%02x", guid->b[i]); module_alias_printf(mod, false, "vmbus:%s", guid_name); } |