[PATCH xquartz 06/10] security: Silence some benign -Wformat warnings

Jeremy Huddleston Sequoia jeremyhu at apple.com
Wed Oct 14 15:13:39 PDT 2015


XID may be either 'unsigned long' or 'unsigned int' depending on:

typedef unsigned long CARD64;
typedef unsigned int CARD32;
typedef unsigned long long CARD64;
typedef unsigned long CARD32;

typedef unsigned long XID;
typedef CARD32 XID;

so when building with -Wformat, we get some warnings that are benign.  This silences them.

security.c:215:52: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
    SecurityAudit("revoked authorization ID %d\n", pAuth->id);
                                            ~~     ^~~~~~~~~
                                            %lu
  CC       dpmsstubs.lo
security.c:553:25: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
                        ^~~~~~~~~
security.c:553:55: warning: format specifies type 'int' but the argument has type 'CARD32' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
                                                      ^~~~~~~~~~~~~~
security.c:554:10: warning: format specifies type 'int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         pAuth->group, eventMask);
         ^~~~~~~~~~~~
security.c:554:24: warning: format specifies type 'int' but the argument has type 'Mask' (aka 'unsigned long')
      [-Wformat,Format String Issue]
         pAuth->group, eventMask);
                       ^~~~~~~~~
security.c:781:19: warning: format specifies type 'unsigned int' but the argument has type 'Mask' (aka 'unsigned
long')
      [-Wformat,Format String Issue]
                  requested, rec->id, cid,
                  ^~~~~~~~~
security.c:781:30: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                  requested, rec->id, cid,
                             ^~~~~~~
security.c:863:23: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                      rec->pWin->drawable.id, wClient(rec->pWin)->index,
                      ^~~~~~~~~~~~~~~~~~~~~~
security.c:893:31: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                              rec->pWin->drawable.id,
                              ^~~~~~~~~~~~~~~~~~~~~~
security.c:915:39: warning: format specifies type 'unsigned int' but the argument has type 'XID' (aka 'unsigned long')
      [-Wformat,Format String Issue]
                  rec->client->index, rec->pWin->drawable.id,
                                      ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
---
 Xext/security.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Xext/security.c b/Xext/security.c
index cce7c46..04382ff 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -212,7 +212,7 @@ SecurityDeleteAuthorization(void *value, XID id)
                 CloseDownClient(clients[i]);
         }
 
-    SecurityAudit("revoked authorization ID %d\n", pAuth->id);
+    SecurityAudit("revoked authorization ID %lu\n", (unsigned long)pAuth->id);
     free(pAuth);
     return Success;
 
@@ -549,9 +549,9 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
     WriteToClient(client, authdata_len, pAuthdata);
 
     SecurityAudit
-        ("client %d generated authorization %d trust %d timeout %d group %d events %d\n",
-         client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
-         pAuth->group, eventMask);
+        ("client %d generated authorization %lu trust %d timeout %lu group %lu events %lu\n",
+         client->index, (unsigned long)pAuth->id, pAuth->trustLevel, (unsigned long)pAuth->timeout,
+         (unsigned long)pAuth->group, (unsigned long)eventMask);
 
     /* the request succeeded; don't call RemoveAuthorization or free pAuth */
     return Success;
@@ -776,9 +776,9 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
             return;
     }
 
-    SecurityAudit("Security: denied client %d access %x to resource 0x%x "
+    SecurityAudit("Security: denied client %d access %lx to resource 0x%lx "
                   "of client %d on request %s\n", rec->client->index,
-                  requested, rec->id, cid,
+                  (unsigned long)requested, (unsigned long)rec->id, cid,
                   SecurityLookupRequestName(rec->client));
     rec->status = BadAccess;    /* deny access */
 }
@@ -858,9 +858,9 @@ SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
 
     if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
         SecurityAudit("Security: denied client %d access to property %s "
-                      "(atom 0x%x) window 0x%x of client %d on request %s\n",
+                      "(atom 0x%x) window 0x%lx of client %d on request %s\n",
                       rec->client->index, NameForAtom(name), name,
-                      rec->pWin->drawable.id, wClient(rec->pWin)->index,
+                      (unsigned long)rec->pWin->drawable.id, wClient(rec->pWin)->index,
                       SecurityLookupRequestName(rec->client));
         rec->status = BadAccess;
     }
@@ -887,10 +887,10 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
                 rec->events[i].u.u.type != ClientMessage) {
 
                 SecurityAudit("Security: denied client %d from sending event "
-                              "of type %s to window 0x%x of client %d\n",
+                              "of type %s to window 0x%lx of client %d\n",
                               rec->client->index,
                               LookupEventName(rec->events[i].u.u.type),
-                              rec->pWin->drawable.id,
+                              (unsigned long)rec->pWin->drawable.id,
                               wClient(rec->pWin)->index);
                 rec->status = BadAccess;
                 return;
@@ -911,8 +911,8 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
         return;
 
     SecurityAudit("Security: denied client %d from receiving an event "
-                  "sent to window 0x%x of client %d\n",
-                  rec->client->index, rec->pWin->drawable.id,
+                  "sent to window 0x%lx of client %d\n",
+                  rec->client->index, (unsigned long)rec->pWin->drawable.id,
                   wClient(rec->pWin)->index);
     rec->status = BadAccess;
 }
-- 
2.6.1



More information about the xorg-devel mailing list