]> git.ipfire.org Git - thirdparty/libvirt.git/commit
maint: avoid potential promotion issues with [ug]id_t
authorEric Blake <eblake@redhat.com>
Mon, 7 Jan 2013 22:50:41 +0000 (15:50 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 8 Jan 2013 15:45:39 +0000 (08:45 -0700)
commit798ff66790fa522f12218e2ad79be2fff71a0c1d
tree31b5485e98eb4734ec61f76fd26be93d6aae905f
parent3aa34af7a63d2c1d65be48eb6fe4ceca1df3b144
maint: avoid potential promotion issues with [ug]id_t

POSIX does not guarantee whether uid_t and gid_t are signed or
unsigned, nor does it guarantee whether they are smaller, same
size, or larger than int (or even the same size as one another).
Therefore, it is possible to have platforms where '(uid_t)-1==-1'
is false or where 'uid = gid = -1' sets uid to the wrong value,
thanks to integer promotion rules.  The only portable way to use
the placeholder value of these two types is to always use a cast.
Thankfully, the issue is mostly theoretical - sanlock only
compiles on Linux for now, and on Linux, these types do not
suffer from strange promotion problems.

* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace, virLockManagerSanlockInit)
(virLockManagerSanlockCreateLease): Cast -1 to proper type before
comparing with uid_t or gid_t.
src/locking/lock_driver_sanlock.c