提交 b7caf4fc 编写于 作者: M Michal Privoznik

virConfGetValueSSizeT: Fix build on 32 bits

This function tries to get a ssize_t value from a config file.
But before returning it, it checks whether the value would fit in
ssize_t and if not an error is printed out among with the range
for the ssize_t type. However, on some platforms SSIZE_MAX may
actually be a signed long type:

util/virconf.c: In function 'virConfGetValueSSizeT':
util/virconf.c:1268:9: error: format '%zd' expects argument of type 'signed size_t', but argument 9 has type 'long int' [-Werror=format=]
         virReportError(VIR_ERR_INTERNAL_ERROR,
         ^
$ grep -r SSIZE_MAX /usr/include/
/usr/include/bits/posix1_lim.h:#ifndef  SSIZE_MAX
/usr/include/bits/posix1_lim.h:# define SSIZE_MAX       LONG_MAX
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 dae3b965
...@@ -1267,7 +1267,8 @@ int virConfGetValueSSizeT(virConfPtr conf, ...@@ -1267,7 +1267,8 @@ int virConfGetValueSSizeT(virConfPtr conf,
if (cval->l > SSIZE_MAX || cval->l < (-SSIZE_MAX - 1)) { if (cval->l > SSIZE_MAX || cval->l < (-SSIZE_MAX - 1)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s: value for '%s' parameter must be in range %zd:%zd"), _("%s: value for '%s' parameter must be in range %zd:%zd"),
conf->filename, setting, -SSIZE_MAX - 1, SSIZE_MAX); conf->filename, setting,
(ssize_t) -SSIZE_MAX - 1, (ssize_t) SSIZE_MAX);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册