diff options
author | Stefan Weil <sw@weilnetz.de> | 2013-12-30 06:35:43 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-01-02 04:47:33 -0500 |
commit | 6e641c943fd5355592b7b955fe3d0f07c927a0aa (patch) | |
tree | 8fe4e4ad8ffb5ea7b0dde6973014308b93d2df9b /Documentation/laptops | |
parent | e0ea041478e03e99f45fa83734c009198a7e3764 (diff) |
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>
Diffstat (limited to 'Documentation/laptops')
-rw-r--r-- | Documentation/laptops/hpfall.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Documentation/laptops/hpfall.c b/Documentation/laptops/hpfall.c index a4a8fc5d05d4..b85dbbac0499 100644 --- a/Documentation/laptops/hpfall.c +++ b/Documentation/laptops/hpfall.c | |||
@@ -29,7 +29,7 @@ int set_unload_heads_path(char *device) | |||
29 | return -EINVAL; | 29 | return -EINVAL; |
30 | strncpy(devname, device + 5, sizeof(devname)); | 30 | strncpy(devname, device + 5, sizeof(devname)); |
31 | 31 | ||
32 | snprintf(unload_heads_path, sizeof(unload_heads_path), | 32 | snprintf(unload_heads_path, sizeof(unload_heads_path) - 1, |
33 | "/sys/block/%s/device/unload_heads", devname); | 33 | "/sys/block/%s/device/unload_heads", devname); |
34 | return 0; | 34 | return 0; |
35 | } | 35 | } |