]> git.ipfire.org Git - thirdparty/util-linux.git/commit - lib/canonicalize.c
lib/canonicalize: fix truncation warning
authorSami Kerola <kerolasa@iki.fi>
Thu, 3 May 2018 21:57:57 +0000 (22:57 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 10 May 2018 09:20:56 +0000 (11:20 +0200)
commitbf99940f649959fcc73590c043d28b1ab0d83e1c
tree678325ccfd9a2c12d981163f5da0b6d131656df5
parent1c199a6e1571ea8f0630e25d05dcdc678f933caf
lib/canonicalize: fix truncation warning

lib/canonicalize.c: In function ‘canonicalize_dm_name’:
lib/canonicalize.c:42:45: warning: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size 244 [-Wformat-truncation=]
   snprintf(path, sizeof(path), "/dev/mapper/%s", name);

Notice that this warnign fix does not improve code enormously.  The earlier
snprintf() truncation will not happen a bit earlier when fgets() is called.
In that sense this change merely makes one easy to silence warning to
disappear, and therefore improve change of noticing useful messaging as such
crops up.

[kzak@redhat.com: - use macro rather than hardcoded string for mapper path]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
include/pathnames.h
lib/canonicalize.c