Skip to contentSkip to conversation

Make Xen headers lint-clean

PATCH In review [email protected] 2 participants 3 messages Jun 14, 2007 – Jun 15, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make Xen headers lint-clean

# HG changeset patch
# User [email protected]
# Date 1181862105 25200
# Node ID b9d1affca0ff606998aee4cd46bd8f6c15fd4b23 # Parent 48ee88f21a3f6f4e92eafb2dec286df156f54cfe Make Xen headers lint-clean

Make ring.h and xs_wire.h lint clean. Add an unused attribute to xsd_errors if using GCC, so we don't get duplicate arrays in every object including the header.

xen/include/public/io/ring.h +1 -1
@@ -139,7 +139,7 @@ typedef struct __name##_back_ring __name
 #define SHARED_RING_INIT(_s) do {                                       \
     (_s)->req_prod  = (_s)->rsp_prod  = 0;                              \
     (_s)->req_event = (_s)->rsp_event = 1;                              \
-    memset((_s)->pad, 0, sizeof((_s)->pad));                            \
+    (void) memset((_s)->pad, 0, sizeof((_s)->pad));                     \
 } while(0)
 
 #define FRONT_RING_INIT(_r, _s, __size) do {                            \
xen/include/public/io/xs_wire.h +6 -1
@@ -60,7 +60,12 @@ struct xsd_errors
     const char *errstring;
 };
 #define XSD_ERROR(x) { x, #x }
-static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
+/* LINTED: static unused */
+static struct xsd_errors xsd_errors[]
+#if defined(__GNUC__)
+__attribute__((unused))
+#endif
+	= {
     XSD_ERROR(EINVAL),
     XSD_ERROR(EACCES),
     XSD_ERROR(EEXIST),
#1 lore raw
Quoted 3 lines · On 15/6/07 00:02, "[email protected]" <[email protected]> wrote:

Make ring.h and xs_wire.h lint clean. Add an unused attribute to xsd_errors if using GCC, so we don't get duplicate arrays in every object including the header.

Casting memset() to void is completely barking. Noone ever cares about the return value, or looks at it: is half the C code in the universe not lint clean therefore?

And xsd_errors[] already has the unused attribute; this patch does not add it as the changeset comment suggests. Do you require to use that header file with a compiler other than gcc?

-- Keir

author
#2 lore raw
Quoted 7 lines · Keir Fraser
Quoted 3 lines

Make ring.h and xs_wire.h lint clean. Add an unused attribute to xsd_errors if using GCC, so we don't get duplicate arrays in every object including the header.

Casting memset() to void is completely barking. Noone ever cares about the return value, or looks at it: is half the C code in the universe not lint clean therefore?

Correct. lint isn't able to differentiate between sensible code and not. Which leaves us with either having one slightly silly piece of code here or maintaining a permanent patch against the file. I don't think it's too ugly to not apply.

Quoted 2 lines

And xsd_errors[] already has the unused attribute; this patch does not add it as the changeset comment suggests.

My apologies, I didn't notice this from forward-porting the patch.

Quoted 1 line

Do you require to use that header file with a compiler other than gcc?

Yes, all the public headers need to be compiled with Sun CC as well. Unfortunately 'unused' is one of the GCC attributes they haven't implemented yet.

regards
john