mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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 fd;
|
||||||
int watch;
|
int watch;
|
||||||
int readonly:1;
|
unsigned int readonly :1;
|
||||||
int closing:1;
|
unsigned int closing :1;
|
||||||
int domain_events_registered:1;
|
unsigned int domain_events_registered :1;
|
||||||
|
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
@ -185,7 +185,7 @@ struct qemud_client {
|
|||||||
int type; /* qemud_sock_type */
|
int type; /* qemud_sock_type */
|
||||||
gnutls_session_t tlssession;
|
gnutls_session_t tlssession;
|
||||||
int auth;
|
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
|
#if HAVE_SASL
|
||||||
sasl_conn_t *saslconn;
|
sasl_conn_t *saslconn;
|
||||||
int saslSSF;
|
int saslSSF;
|
||||||
@ -244,9 +244,9 @@ struct qemud_socket {
|
|||||||
|
|
||||||
struct qemud_worker {
|
struct qemud_worker {
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
int hasThread :1;
|
unsigned int hasThread :1;
|
||||||
int processingCall :1;
|
unsigned int processingCall :1;
|
||||||
int quitRequest : 1;
|
unsigned int quitRequest :1;
|
||||||
|
|
||||||
/* back-pointer to our server */
|
/* back-pointer to our server */
|
||||||
struct qemud_server *server;
|
struct qemud_server *server;
|
||||||
|
@ -400,8 +400,8 @@ enum virDomainVideoType {
|
|||||||
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
|
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
|
||||||
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
|
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
|
||||||
struct _virDomainVideoAccelDef {
|
struct _virDomainVideoAccelDef {
|
||||||
int support3d : 1;
|
unsigned int support3d :1;
|
||||||
int support2d : 1;
|
unsigned int support2d :1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ struct _virDomainGraphicsDef {
|
|||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int port;
|
int port;
|
||||||
int autoport : 1;
|
unsigned int autoport :1;
|
||||||
char *listenAddr;
|
char *listenAddr;
|
||||||
char *keymap;
|
char *keymap;
|
||||||
char *passwd;
|
char *passwd;
|
||||||
@ -445,13 +445,13 @@ struct _virDomainGraphicsDef {
|
|||||||
struct {
|
struct {
|
||||||
int port;
|
int port;
|
||||||
char *listenAddr;
|
char *listenAddr;
|
||||||
int autoport : 1;
|
unsigned int autoport :1;
|
||||||
int replaceUser : 1;
|
unsigned int replaceUser :1;
|
||||||
int multiUser : 1;
|
unsigned int multiUser :1;
|
||||||
} rdp;
|
} rdp;
|
||||||
struct {
|
struct {
|
||||||
char *display;
|
char *display;
|
||||||
int fullscreen : 1;
|
unsigned int fullscreen :1;
|
||||||
} desktop;
|
} desktop;
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
@ -164,7 +164,7 @@ typedef virInterfaceObj *virInterfaceObjPtr;
|
|||||||
struct _virInterfaceObj {
|
struct _virInterfaceObj {
|
||||||
virMutex lock;
|
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 */
|
virInterfaceDefPtr def; /* The interface definition */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ struct _virNetworkDef {
|
|||||||
char *bridge; /* Name of bridge device */
|
char *bridge; /* Name of bridge device */
|
||||||
char *domain;
|
char *domain;
|
||||||
unsigned long delay; /* Bridge forward delay (ms) */
|
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 */
|
int forwardType; /* One of virNetworkForwardType constants */
|
||||||
char *forwardDev; /* Destination device for forwarding */
|
char *forwardDev; /* Destination device for forwarding */
|
||||||
|
Loading…
Reference in New Issue
Block a user