mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 11:35:19 +00:00
build: avoid compiler warning
Necessary on cygwin, where uid_t and gid_t are 4-byte long rather than int, causing gcc -Wformat warnings. * src/util/util.c (virFileOperationNoFork, virDirCreateNoFork) (virFileOperation, virDirCreate, virGetUserEnt): Cast uid_t and gid_t before passing to printf. * .gitignore: Ignore Windows executables.
This commit is contained in:
parent
018fd697b6
commit
7f31e28c6e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
*#*#
|
*#*#
|
||||||
*.#*#
|
*.#*#
|
||||||
*.a
|
*.a
|
||||||
|
*.exe
|
||||||
*.o
|
*.o
|
||||||
*.orig
|
*.orig
|
||||||
*.rej
|
*.rej
|
||||||
|
@ -74,11 +74,15 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "threads.h"
|
#include "threads.h"
|
||||||
|
#include "verify.h"
|
||||||
|
|
||||||
#ifndef NSIG
|
#ifndef NSIG
|
||||||
# define NSIG 32
|
# define NSIG 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
verify(sizeof(gid_t) <= sizeof (unsigned int) &&
|
||||||
|
sizeof(uid_t) <= sizeof (unsigned int));
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#define virUtilError(code, ...) \
|
#define virUtilError(code, ...) \
|
||||||
@ -1277,7 +1281,7 @@ static int virFileOperationNoFork(const char *path, int openflags, mode_t mode,
|
|||||||
&& (fchown(fd, uid, gid) < 0)) {
|
&& (fchown(fd, uid, gid) < 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
||||||
path, uid, gid);
|
path, (unsigned int) uid, (unsigned int) gid);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if ((flags & VIR_FILE_OP_FORCE_PERMS)
|
if ((flags & VIR_FILE_OP_FORCE_PERMS)
|
||||||
@ -1328,7 +1332,7 @@ static int virDirCreateNoFork(const char *path, mode_t mode, uid_t uid, gid_t gi
|
|||||||
&& (chown(path, uid, gid) < 0)) {
|
&& (chown(path, uid, gid) < 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
||||||
path, uid, gid);
|
path, (unsigned int) uid, (unsigned int) gid);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
|
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
|
||||||
@ -1407,14 +1411,14 @@ parenterror:
|
|||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot set gid %u creating '%s'"),
|
_("cannot set gid %u creating '%s'"),
|
||||||
gid, path);
|
(unsigned int) gid, path);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if ((uid != 0) && (setuid(uid) != 0)) {
|
if ((uid != 0) && (setuid(uid) != 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot set uid %u creating '%s'"),
|
_("cannot set uid %u creating '%s'"),
|
||||||
uid, path);
|
(unsigned int) uid, path);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if ((fd = open(path, openflags, mode)) < 0) {
|
if ((fd = open(path, openflags, mode)) < 0) {
|
||||||
@ -1436,7 +1440,7 @@ parenterror:
|
|||||||
&& (fchown(fd, -1, gid) < 0)) {
|
&& (fchown(fd, -1, gid) < 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
|
||||||
path, uid, gid);
|
path, (unsigned int) uid, (unsigned int) gid);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if ((flags & VIR_FILE_OP_FORCE_PERMS)
|
if ((flags & VIR_FILE_OP_FORCE_PERMS)
|
||||||
@ -1517,13 +1521,13 @@ parenterror:
|
|||||||
if ((gid != 0) && (setgid(gid) != 0)) {
|
if ((gid != 0) && (setgid(gid) != 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno, _("cannot set gid %u creating '%s'"),
|
virReportSystemError(errno, _("cannot set gid %u creating '%s'"),
|
||||||
gid, path);
|
(unsigned int) gid, path);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if ((uid != 0) && (setuid(uid) != 0)) {
|
if ((uid != 0) && (setuid(uid) != 0)) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno, _("cannot set uid %u creating '%s'"),
|
virReportSystemError(errno, _("cannot set uid %u creating '%s'"),
|
||||||
uid, path);
|
(unsigned int) uid, path);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if (mkdir(path, mode) < 0) {
|
if (mkdir(path, mode) < 0) {
|
||||||
@ -1547,7 +1551,7 @@ parenterror:
|
|||||||
ret = errno;
|
ret = errno;
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot chown '%s' to group %u"),
|
_("cannot chown '%s' to group %u"),
|
||||||
path, gid);
|
path, (unsigned int) gid);
|
||||||
goto childerror;
|
goto childerror;
|
||||||
}
|
}
|
||||||
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
|
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
|
||||||
@ -2563,8 +2567,8 @@ static char *virGetUserEnt(uid_t uid,
|
|||||||
*/
|
*/
|
||||||
if (getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) {
|
if (getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to find user record for uid '%d'"),
|
_("Failed to find user record for uid '%u'"),
|
||||||
uid);
|
(unsigned int) uid);
|
||||||
VIR_FREE(strbuf);
|
VIR_FREE(strbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user