summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2009-01-29 15:01:06 -0200
committerPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2009-01-29 15:01:06 -0200
commita1977883c9f5ef0e515569d6e2ebccb07411f98c (patch)
tree7b94215aca564ed1a43c371a3d47422faaffa77f
parent8ba0ca32a63c532f128bdca7f1bf982cab8e12be (diff)
Janitor: Correct some gcc/sparse warnings.
Most remaining warnings are about XIM/Xim to/from conversion and discarding const from pointers.
-rw-r--r--modules/im/ximcp/imTrX.c2
-rw-r--r--src/Host.c24
-rw-r--r--src/StBytes.c2
-rw-r--r--src/util/makekeys.c10
-rw-r--r--src/xcb_disp.c8
-rw-r--r--src/xcb_io.c22
6 files changed, 32 insertions, 36 deletions
diff --git a/modules/im/ximcp/imTrX.c b/modules/im/ximcp/imTrX.c
index 2b085964..b9a9f678 100644
--- a/modules/im/ximcp/imTrX.c
+++ b/modules/im/ximcp/imTrX.c
@@ -439,7 +439,7 @@ _XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len)
{
XEvent *ev;
XEvent event;
- int len;
+ int len = 0;
XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
XPointer arg = spec->ev;
diff --git a/src/Host.c b/src/Host.c
index 73d87085..a25e275f 100644
--- a/src/Host.c
+++ b/src/Host.c
@@ -54,12 +54,10 @@ XAddHost (
XServerInterpretedAddress *siAddr;
int addrlen;
- if (host->family == FamilyServerInterpreted) {
- siAddr = (XServerInterpretedAddress *) host->address;
- addrlen = siAddr->typelength + siAddr->valuelength + 1;
- } else {
- addrlen = host->length;
- }
+ siAddr = host->family == FamilyServerInterpreted ?
+ (XServerInterpretedAddress *)host->address : NULL;
+ addrlen = siAddr ?
+ siAddr->typelength + siAddr->valuelength + 1 : host->length;
length = (addrlen + 3) & ~0x3; /* round up */
@@ -68,7 +66,7 @@ XAddHost (
req->mode = HostInsert;
req->hostFamily = host->family;
req->hostLength = addrlen;
- if (host->family == FamilyServerInterpreted) {
+ if (siAddr) {
char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
memcpy(dest, siAddr->type, siAddr->typelength);
dest[siAddr->typelength] = '\0';
@@ -91,12 +89,10 @@ XRemoveHost (
XServerInterpretedAddress *siAddr;
int addrlen;
- if (host->family == FamilyServerInterpreted) {
- siAddr = (XServerInterpretedAddress *) host->address;
- addrlen = siAddr->typelength + siAddr->valuelength + 1;
- } else {
- addrlen = host->length;
- }
+ siAddr = host->family == FamilyServerInterpreted ?
+ (XServerInterpretedAddress *)host->address : NULL;
+ addrlen = siAddr ?
+ siAddr->typelength + siAddr->valuelength + 1 : host->length;
length = (addrlen + 3) & ~0x3; /* round up */
@@ -105,7 +101,7 @@ XRemoveHost (
req->mode = HostDelete;
req->hostFamily = host->family;
req->hostLength = addrlen;
- if (host->family == FamilyServerInterpreted) {
+ if (siAddr) {
char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
memcpy(dest, siAddr->type, siAddr->typelength);
dest[siAddr->typelength] = '\0';
diff --git a/src/StBytes.c b/src/StBytes.c
index cc413623..f6a7788d 100644
--- a/src/StBytes.c
+++ b/src/StBytes.c
@@ -51,7 +51,7 @@ XRotateBuffers (
/* XRotateWindowProperties wants a non-const Atom*, but it doesn't
* modify it, so this is safe.
*/
- return XRotateWindowProperties(dpy, RootWindow(dpy, 0), n_to_atom, 8, rotate);
+ return XRotateWindowProperties(dpy, RootWindow(dpy, 0), (Atom *)n_to_atom, 8, rotate);
}
char *XFetchBuffer (
diff --git a/src/util/makekeys.c b/src/util/makekeys.c
index 4ea447fa..eacd1803 100644
--- a/src/util/makekeys.c
+++ b/src/util/makekeys.c
@@ -52,11 +52,11 @@ static struct info {
#define MIN_REHASH 15
#define MATCHES 10
-char tab[KTNUM];
-unsigned short offsets[KTNUM];
-unsigned short indexes[KTNUM];
-KeySym values[KTNUM];
-char buf[1024];
+static char tab[KTNUM];
+static unsigned short offsets[KTNUM];
+static unsigned short indexes[KTNUM];
+static KeySym values[KTNUM];
+static char buf[1024];
int
main(int argc, char *argv[])
diff --git a/src/xcb_disp.c b/src/xcb_disp.c
index 628c6545..d9760646 100644
--- a/src/xcb_disp.c
+++ b/src/xcb_disp.c
@@ -16,11 +16,11 @@ static void *alloc_copy(const void *src, int *dstn, size_t n)
if(n <= 0)
{
*dstn = 0;
- return 0;
+ return NULL;
}
dst = Xmalloc(n);
if(!dst)
- return 0;
+ return NULL;
memcpy(dst, src, n);
*dstn = n;
return dst;
@@ -82,9 +82,9 @@ int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *scr
_XLockMutex(_Xglobal_lock);
if(xauth.name && xauth.data)
- c = xcb_connect_to_display_with_auth_info(display, &xauth, 0);
+ c = xcb_connect_to_display_with_auth_info(display, &xauth, NULL);
else
- c = xcb_connect(display, 0);
+ c = xcb_connect(display, NULL);
_XUnlockMutex(_Xglobal_lock);
dpy->fd = xcb_get_file_descriptor(c);
diff --git a/src/xcb_io.c b/src/xcb_io.c
index 73822b22..96b82b86 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -17,7 +17,7 @@ static void return_socket(void *closure)
{
Display *dpy = closure;
LockDisplay(dpy);
- _XSend(dpy, 0, 0);
+ _XSend(dpy, NULL, 0);
dpy->bufmax = dpy->buffer;
UnlockDisplay(dpy);
}
@@ -200,7 +200,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
/* This can only occur when called from
* _XReply, which doesn't need a new event. */
*current_error = (xcb_generic_error_t *) event;
- event = 0;
+ event = NULL;
break;
}
else
@@ -250,10 +250,10 @@ int _XEventsQueued(Display *dpy, int mode)
return 0;
if(mode == QueuedAfterFlush)
- _XSend(dpy, 0, 0);
+ _XSend(dpy, NULL, 0);
else
check_internal_connections(dpy);
- process_responses(dpy, 0, 0, 0);
+ process_responses(dpy, 0, NULL, 0);
return dpy->qlen;
}
@@ -264,12 +264,12 @@ void _XReadEvents(Display *dpy)
{
if(dpy->flags & XlibDisplayIOError)
return;
- _XSend(dpy, 0, 0);
+ _XSend(dpy, NULL, 0);
if(dpy->xcb->event_owner != XlibOwnsEventQueue)
return;
check_internal_connections(dpy);
do {
- process_responses(dpy, 1, 0, 0);
+ process_responses(dpy, 1, NULL, 0);
} while (dpy->qlen == 0);
}
@@ -305,7 +305,7 @@ void _XSend(Display *dpy, const char *data, long size)
{
PendingRequest *req = malloc(sizeof(PendingRequest));
assert(req);
- req->next = 0;
+ req->next = NULL;
req->sequence = sequence;
*dpy->xcb->pending_requests_tail = req;
dpy->xcb->pending_requests_tail = &req->next;
@@ -346,7 +346,7 @@ void _XSend(Display *dpy, const char *data, long size)
void _XFlush(Display *dpy)
{
require_socket(dpy);
- _XSend(dpy, 0, 0);
+ _XSend(dpy, NULL, 0);
_XEventsQueued(dpy, QueuedAfterReading);
}
@@ -408,7 +408,7 @@ static void _XFreeReplyData(Display *dpy, Bool force)
if(!force && dpy->xcb->reply_consumed < dpy->xcb->reply_length)
return;
free(dpy->xcb->reply_data);
- dpy->xcb->reply_data = 0;
+ dpy->xcb->reply_data = NULL;
}
static PendingRequest * insert_pending_request(Display *dpy)
@@ -447,7 +447,7 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
if(dpy->flags & XlibDisplayIOError)
return 0;
- _XSend(dpy, 0, 0);
+ _XSend(dpy, NULL, 0);
current = insert_pending_request(dpy);
/* FIXME: drop the Display lock while waiting?
* Complicates process_responses. */
@@ -539,7 +539,7 @@ int _XRead(Display *dpy, char *data, long size)
assert(size >= 0);
if(size == 0)
return 0;
- assert(dpy->xcb->reply_data != 0);
+ assert(dpy->xcb->reply_data != NULL);
assert(dpy->xcb->reply_consumed + size <= dpy->xcb->reply_length);
memcpy(data, dpy->xcb->reply_data + dpy->xcb->reply_consumed, size);
dpy->xcb->reply_consumed += size;