]> xenbits.xensource.com Git - libvirt.git/commitdiff
maint: avoid further typedef accidents
authorEric Blake <eblake@redhat.com>
Tue, 29 Oct 2013 19:57:19 +0000 (13:57 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 30 Oct 2013 23:02:12 +0000 (17:02 -0600)
To make it easier to forbid future attempts at a confusing typedef
name ending in Ptr that isn't actually a pointer, insist that we
follow our preferred style of 'typedef foo *fooPtr'.

* cfg.mk (sc_forbid_const_pointer_typedef): Enforce consistent
style, to prevent issue fixed in previous storage patch.
* src/conf/capabilities.h (virCapsPtr): Fix offender.
* src/security/security_stack.c (virSecurityStackItemPtr):
Likewise.
* tests/qemucapabilitiestest.c (testQemuDataPtr): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
cfg.mk
src/conf/capabilities.h
src/security/security_stack.c
tests/qemucapabilitiestest.c

diff --git a/cfg.mk b/cfg.mk
index e9da28210d5baa707ca90a95bf9bfb7897c1a7c8..1b2fd464cce7ede97d61246c6c2eb39b48a658a6 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -471,10 +471,14 @@ sc_correct_id_types:
 # "const fooPtr a" is the same as "foo * const a", even though it is
 # usually desired to have "foo const *a".  It's easier to just prevent
 # the confusing mix of typedef vs. const placement.
+# Also requires that all 'fooPtr' typedefs are actually pointers.
 sc_forbid_const_pointer_typedef:
        @prohibit='(^|[^"])const \w*Ptr'                                \
        halt='"const fooPtr var" does not declare what you meant'       \
          $(_sc_search_regexp)
+       @prohibit='typedef [^(]+ [^*]\w*Ptr\b'                          \
+       halt='use correct style and type for Ptr typedefs'              \
+         $(_sc_search_regexp)
 
 # Forbid sizeof foo or sizeof (foo), require sizeof(foo)
 sc_size_of_brackets:
index 5bc7bb502343a973eb2fe42a4a4edfa600059973..ba99e1a393c7d75f42c29e5c338c6c7a62234a15 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * capabilities.h: hypervisor capabilities
  *
- * Copyright (C) 2006-2008, 2010, 2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -162,7 +162,7 @@ struct _virDomainXMLNamespace {
 };
 
 typedef struct _virCaps virCaps;
-typedef virCapsvirCapsPtr;
+typedef virCaps *virCapsPtr;
 struct _virCaps {
     virObject parent;
 
index ff0f06b1bfcb8cc12241a14df9b46787fff40893..0d42b21634a27074bfba44c7efda00d729031932 100644 (file)
@@ -30,7 +30,7 @@
 typedef struct _virSecurityStackData virSecurityStackData;
 typedef virSecurityStackData *virSecurityStackDataPtr;
 typedef struct _virSecurityStackItem virSecurityStackItem;
-typedef virSecurityStackItemvirSecurityStackItemPtr;
+typedef virSecurityStackItem *virSecurityStackItemPtr;
 
 struct _virSecurityStackItem {
     virSecurityManagerPtr securityManager;
index 28f12e7af92aa928f280553945cce18197f888cf..d9121715e7bbb963be00e96140fd8ee59c8a2138 100644 (file)
@@ -27,7 +27,7 @@
 #define VIR_FROM_THIS VIR_FROM_NONE
 
 typedef struct _testQemuData testQemuData;
-typedef testQemuData * testQemuDataPtr;
+typedef testQemuData *testQemuDataPtr;
 struct _testQemuData {
     virDomainXMLOptionPtr xmlopt;
     const char *base;