crash_dump: Remove redundant less-than-zero check
Subsystems (3)
PATCH 1/1 crash_dump: Remove redundant less-than-zero check
'key_count' is an 'unsigned int' and cannot be less than zero. Remove the redundant condition.
Signed-off-by Thorsten Blum <[email protected]>
--- kernel/crash_dump_dm_crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/crash_dump_dm_crypt.c +1 -1
@@ -115,7 +115,7 @@ static int restore_dm_crypt_keys_to_thread_keyring(void) addr = dm_crypt_keys_addr;dm_crypt_keys_read ((char *)&key_count,sizeof (key_count), &addr); -if (key_count <0 || key_count >KEY_NUM_MAX ) { +if (key_count >KEY_NUM_MAX ) {kexec_dprintk ("Failed to read the number of dm-crypt keys\n" );return -1 ; }
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Andrew Morton
maintainerQuoted 3 lines · On Sat, 28 Feb 2026 09:51:36 +0100 Thorsten Blum <[email protected]>…
'
key_count' is an 'unsigned int' and cannot be less than zero. Remove the redundant condition.
umm. OK.
kernel/crash_dump_dm_crypt.c static int restore_dm_crypt_keys_to_thread_keyring(void) · line 121
Quoted 11 lines
kernel/crash_dump_dm_crypt.c +1
-1@@ -115,7 +115,7 @@ static int restore_dm_crypt_keys_to_thread_keyring(void) addr = dm_crypt_keys_addr;dm_crypt_keys_read ((char *)&key_count,sizeof (key_count), &addr); -if (key_count <0 || key_count >KEY_NUM_MAX ) { +if (key_count >KEY_NUM_MAX ) {kexec_dprintk ("Failed to read the number of dm-crypt keys\n" );return -1 ; }
iirc Linus has said "this is OK". The compiler will eliminate it and the code still works if the type is later changed to signed.