mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
Documentation: Fix size parameter for snprintf
cppcheck reports this error: Documentation/laptops/hpfall.c:33]: (error) Dangerous usage of 'devname' (strncpy doesn't always 0-terminate it) The terminating '\0' is needed for the global char array unload_heads_path, so never write the last array entry (which is initially '\0'). Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
e0ea041478
commit
6e641c943f
1 changed files with 1 additions and 1 deletions
|
@ -29,7 +29,7 @@ int set_unload_heads_path(char *device)
|
|||
return -EINVAL;
|
||||
strncpy(devname, device + 5, sizeof(devname));
|
||||
|
||||
snprintf(unload_heads_path, sizeof(unload_heads_path),
|
||||
snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
|
||||
"/sys/block/%s/device/unload_heads", devname);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue