1
0

maint: avoid further typedef accidents

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>
This commit is contained in:
Eric Blake 2013-10-29 13:57:19 -06:00
parent 5eb3dff5b6
commit fb8613525d
4 changed files with 8 additions and 4 deletions

4
cfg.mk
View File

@ -471,10 +471,14 @@ sc_correct_id_types:
# "const fooPtr a" is the same as "foo * const a", even though it is # "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 # usually desired to have "foo const *a". It's easier to just prevent
# the confusing mix of typedef vs. const placement. # the confusing mix of typedef vs. const placement.
# Also requires that all 'fooPtr' typedefs are actually pointers.
sc_forbid_const_pointer_typedef: sc_forbid_const_pointer_typedef:
@prohibit='(^|[^"])const \w*Ptr' \ @prohibit='(^|[^"])const \w*Ptr' \
halt='"const fooPtr var" does not declare what you meant' \ halt='"const fooPtr var" does not declare what you meant' \
$(_sc_search_regexp) $(_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) # Forbid sizeof foo or sizeof (foo), require sizeof(foo)
sc_size_of_brackets: sc_size_of_brackets:

View File

@ -1,7 +1,7 @@
/* /*
* capabilities.h: hypervisor capabilities * 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 * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -162,7 +162,7 @@ struct _virDomainXMLNamespace {
}; };
typedef struct _virCaps virCaps; typedef struct _virCaps virCaps;
typedef virCaps* virCapsPtr; typedef virCaps *virCapsPtr;
struct _virCaps { struct _virCaps {
virObject parent; virObject parent;

View File

@ -30,7 +30,7 @@
typedef struct _virSecurityStackData virSecurityStackData; typedef struct _virSecurityStackData virSecurityStackData;
typedef virSecurityStackData *virSecurityStackDataPtr; typedef virSecurityStackData *virSecurityStackDataPtr;
typedef struct _virSecurityStackItem virSecurityStackItem; typedef struct _virSecurityStackItem virSecurityStackItem;
typedef virSecurityStackItem* virSecurityStackItemPtr; typedef virSecurityStackItem *virSecurityStackItemPtr;
struct _virSecurityStackItem { struct _virSecurityStackItem {
virSecurityManagerPtr securityManager; virSecurityManagerPtr securityManager;

View File

@ -27,7 +27,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE #define VIR_FROM_THIS VIR_FROM_NONE
typedef struct _testQemuData testQemuData; typedef struct _testQemuData testQemuData;
typedef testQemuData * testQemuDataPtr; typedef testQemuData *testQemuDataPtr;
struct _testQemuData { struct _testQemuData {
virDomainXMLOptionPtr xmlopt; virDomainXMLOptionPtr xmlopt;
const char *base; const char *base;