mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
Make all bitfields unsigned ints to avoid unexpected values in casts
The 'int virInterfaceIsActive()' method was directly returning the value of the 'int active:1' bitfield in virIntefaceDefPtr. A bitfield with a signed integer, will hold the values 0 and -1, not 0 and +1 as might be expected. This meant that virInterfaceIsActive() was always returning -1 when the interface was active, not +1 & thus all callers thought an error had occurred. To protect against this kind of mistake again, change all bitfields to be unsigned ints * daemon/libvirtd.h, src/conf/domain_conf.h, src/conf/interface_conf.h, src/conf/network_conf.h: Change bitfields to unsigned int.
This commit is contained in:
parent
ed00e45dba
commit
50b6c95d62
@ -175,9 +175,9 @@ struct qemud_client {
|
||||
|
||||
int fd;
|
||||
int watch;
|
||||
int readonly:1;
|
||||
int closing:1;
|
||||
int domain_events_registered:1;
|
||||
unsigned int readonly :1;
|
||||
unsigned int closing :1;
|
||||
unsigned int domain_events_registered :1;
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen;
|
||||
@ -185,7 +185,7 @@ struct qemud_client {
|
||||
int type; /* qemud_sock_type */
|
||||
gnutls_session_t tlssession;
|
||||
int auth;
|
||||
int handshake : 1; /* If we're in progress for TLS handshake */
|
||||
unsigned int handshake :1; /* If we're in progress for TLS handshake */
|
||||
#if HAVE_SASL
|
||||
sasl_conn_t *saslconn;
|
||||
int saslSSF;
|
||||
@ -244,9 +244,9 @@ struct qemud_socket {
|
||||
|
||||
struct qemud_worker {
|
||||
pthread_t thread;
|
||||
int hasThread :1;
|
||||
int processingCall :1;
|
||||
int quitRequest : 1;
|
||||
unsigned int hasThread :1;
|
||||
unsigned int processingCall :1;
|
||||
unsigned int quitRequest :1;
|
||||
|
||||
/* back-pointer to our server */
|
||||
struct qemud_server *server;
|
||||
|
@ -400,8 +400,8 @@ enum virDomainVideoType {
|
||||
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
|
||||
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
|
||||
struct _virDomainVideoAccelDef {
|
||||
int support3d : 1;
|
||||
int support2d : 1;
|
||||
unsigned int support3d :1;
|
||||
unsigned int support2d :1;
|
||||
};
|
||||
|
||||
|
||||
@ -432,7 +432,7 @@ struct _virDomainGraphicsDef {
|
||||
union {
|
||||
struct {
|
||||
int port;
|
||||
int autoport : 1;
|
||||
unsigned int autoport :1;
|
||||
char *listenAddr;
|
||||
char *keymap;
|
||||
char *passwd;
|
||||
@ -445,13 +445,13 @@ struct _virDomainGraphicsDef {
|
||||
struct {
|
||||
int port;
|
||||
char *listenAddr;
|
||||
int autoport : 1;
|
||||
int replaceUser : 1;
|
||||
int multiUser : 1;
|
||||
unsigned int autoport :1;
|
||||
unsigned int replaceUser :1;
|
||||
unsigned int multiUser :1;
|
||||
} rdp;
|
||||
struct {
|
||||
char *display;
|
||||
int fullscreen : 1;
|
||||
unsigned int fullscreen :1;
|
||||
} desktop;
|
||||
} data;
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ typedef virInterfaceObj *virInterfaceObjPtr;
|
||||
struct _virInterfaceObj {
|
||||
virMutex lock;
|
||||
|
||||
int active:1; /* 1 if interface is active (up) */
|
||||
unsigned int active:1; /* 1 if interface is active (up) */
|
||||
virInterfaceDefPtr def; /* The interface definition */
|
||||
};
|
||||
|
||||
|
@ -65,7 +65,7 @@ struct _virNetworkDef {
|
||||
char *bridge; /* Name of bridge device */
|
||||
char *domain;
|
||||
unsigned long delay; /* Bridge forward delay (ms) */
|
||||
int stp : 1; /* Spanning tree protocol */
|
||||
unsigned int stp :1; /* Spanning tree protocol */
|
||||
|
||||
int forwardType; /* One of virNetworkForwardType constants */
|
||||
char *forwardDev; /* Destination device for forwarding */
|
||||
|
Loading…
Reference in New Issue
Block a user