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(a)redhat.com>
---
cfg.mk | 4 ++++
src/conf/capabilities.h | 4 ++--
src/security/security_stack.c | 2 +-
tests/qemucapabilitiestest.c | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index e9da282..1b2fd46 100644
--- 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:
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 5bc7bb5..ba99e1a 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -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 virCaps* virCapsPtr;
+typedef virCaps *virCapsPtr;
struct _virCaps {
virObject parent;
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index ff0f06b..0d42b21 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -30,7 +30,7 @@
typedef struct _virSecurityStackData virSecurityStackData;
typedef virSecurityStackData *virSecurityStackDataPtr;
typedef struct _virSecurityStackItem virSecurityStackItem;
-typedef virSecurityStackItem* virSecurityStackItemPtr;
+typedef virSecurityStackItem *virSecurityStackItemPtr;
struct _virSecurityStackItem {
virSecurityManagerPtr securityManager;
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 28f12e7..d912171 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -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;
--
1.8.3.1