sys-utils/zramctl.c: In function ‘zram_get_sysfs’:
sys-utils/zramctl.c:220:52: warning: ‘%s’ directive output may be truncated
writing up to 4095 bytes into a region of size 27 [-Wformat-truncation=]
snprintf(z->devname, sizeof(z->devname), "/dev/%s", name);
As an additional good thing zramctl will no longer allocate 4096 bytes from
stack when just 23 bytes is enough.
[kzak@redhat.com: - use macro rather than hardcoded string for the path]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
return NULL;
if (*z->devname != '/') {
/* canonicalize the device name according to /sys */
- char name[PATH_MAX];
+ char name[sizeof(z->devname) - sizeof(_PATH_DEV)];
if (sysfs_get_devname(&z->sysfs, name, sizeof(name)))
- snprintf(z->devname, sizeof(z->devname), "/dev/%s", name);
+ snprintf(z->devname, sizeof(z->devname), _PATH_DEV "%s", name);
}
}