summaryrefslogtreecommitdiff
path: root/src/fdstream.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-07-07 11:57:43 -0600
committerEric Blake <eblake@redhat.com>2011-07-15 16:37:30 -0600
commit761bbb17c7b7b3bf4a89e9f932c4340986aba278 (patch)
tree2487ea8f5213c69aba90c6a4c83aea3164689088 /src/fdstream.c
parent6a713b310a08a4f28d21bd59fa216a0f8a571536 (diff)
downloadlibvirt-761bbb17c7b7b3bf4a89e9f932c4340986aba278.tar.gz
build: add syntax check for proper flags use
Enforce the recent flags cleanups - we want to use 'unsigned int flags' in any of our APIs (except where backwards compatibility is important, in the public migration APIs), and that all flags are checked for validity (except when there are stub functions that completely ignore the flags argument). There are a few minor tweaks done here to avoid false positives: signed arguments passed to open() are renamed oflags, and flags arguments that are legitimately ignored are renamed flags_unused. * cfg.mk (sc_flags_usage): New rule. (exclude_file_name_regexp--sc_flags_usage): And a few exemptions. (sc_flags_debug): Tweak wording. * src/util/iohelper.c (runIO, main): Rename variable. * src/util/util.c (virSetInherit): Likewise. * src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile): Likewise. * src/fdstream.c (virFDStreamOpenFileInternal) (virFDStreamOpenFile, virFDStreamCreateFile): Likewise. * src/util/command.c (virExecWithHook) [WIN32]: Likewise. * src/util/util.c (virFileOpenAs, virDirCreate) [WIN32]: Likewise. * src/locking/lock_manager.c (virLockManagerPluginNew) [!HAVE_DLFCN_H]: Likewise. * src/locking/lock_driver_nop.c (virLockManagerNopNew) (virLockManagerNopAddResource, virLockManagerNopAcquire) (virLockManagerNopRelease, virLockManagerNopInquire): Likewise.
Diffstat (limited to 'src/fdstream.c')
-rw-r--r--src/fdstream.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/fdstream.c b/src/fdstream.c
index 4dbe4a3ef7..dd742e1980 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -504,7 +504,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
const char *path,
unsigned long long offset,
unsigned long long length,
- int flags,
+ int oflags,
int mode,
bool delete)
{
@@ -514,13 +514,13 @@ virFDStreamOpenFileInternal(virStreamPtr st,
virCommandPtr cmd = NULL;
int errfd = -1;
- VIR_DEBUG("st=%p path=%s flags=%x offset=%llu length=%llu mode=%o delete=%d",
- st, path, flags, offset, length, mode, delete);
+ VIR_DEBUG("st=%p path=%s oflags=%x offset=%llu length=%llu mode=%o delete=%d",
+ st, path, oflags, offset, length, mode, delete);
- if (flags & O_CREAT)
- fd = open(path, flags, mode);
+ if (oflags & O_CREAT)
+ fd = open(path, oflags, mode);
else
- fd = open(path, flags);
+ fd = open(path, oflags);
if (fd < 0) {
virReportSystemError(errno,
_("Unable to open stream for '%s'"),
@@ -545,7 +545,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
!S_ISFIFO(sb.st_mode))) {
int childfd;
- if ((flags & O_RDWR) == O_RDWR) {
+ if ((oflags & O_RDWR) == O_RDWR) {
streamsReportError(VIR_ERR_INTERNAL_ERROR,
_("%s: Cannot request read and write flags together"),
path);
@@ -562,7 +562,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper",
path,
NULL);
- virCommandAddArgFormat(cmd, "%d", flags);
+ virCommandAddArgFormat(cmd, "%d", oflags);
virCommandAddArgFormat(cmd, "%d", mode);
virCommandAddArgFormat(cmd, "%llu", offset);
virCommandAddArgFormat(cmd, "%llu", length);
@@ -575,7 +575,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
*/
delete = false;
- if (flags == O_RDONLY) {
+ if (oflags == O_RDONLY) {
childfd = fds[1];
fd = fds[0];
virCommandSetOutputFD(cmd, &childfd);
@@ -620,10 +620,10 @@ int virFDStreamOpenFile(virStreamPtr st,
const char *path,
unsigned long long offset,
unsigned long long length,
- int flags,
+ int oflags,
bool delete)
{
- if (flags & O_CREAT) {
+ if (oflags & O_CREAT) {
streamsReportError(VIR_ERR_INTERNAL_ERROR,
_("Attempt to create %s without specifying mode"),
path);
@@ -631,19 +631,19 @@ int virFDStreamOpenFile(virStreamPtr st,
}
return virFDStreamOpenFileInternal(st, path,
offset, length,
- flags, 0, delete);
+ oflags, 0, delete);
}
int virFDStreamCreateFile(virStreamPtr st,
const char *path,
unsigned long long offset,
unsigned long long length,
- int flags,
+ int oflags,
mode_t mode,
bool delete)
{
return virFDStreamOpenFileInternal(st, path,
offset, length,
- flags | O_CREAT,
+ oflags | O_CREAT,
mode, delete);
}