Merge lp:~bregma/geis/sentinel-check into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 254
Proposed branch: lp:~bregma/geis/sentinel-check
Merge into: lp:geis
Diff against target: 64 lines (+15/-7)
2 files modified
include/geis/geis.h (+7/-7)
libutouch-geis/geis/geisimpl.h (+8/-0)
To merge this branch: bzr merge lp:~bregma/geis/sentinel-check
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Review via email: mp+102701@code.launchpad.net

Description of the change

Adds a GCC attribute to warn when a NULL terminator is missing from a variadic argument list.

No new tests are supplied: the functionality of this tweak can be verified by manually removing the terminating NULL from a geis_new() or geis_filter_add_term() call and attempting to build the test suite. Unlike older established tools, our test tools can not handle expected compile failures so testing must be done manually.

This change closes no bugs but reduces the incidents of help requests due to incorrect use of the API.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote :

The change is definitely good to have. +1.

I don't think we need a test for this because it merely emits a warning, but we could actually provide a test if we wanted to. I wrote a compile test for utouch-frame _Generic support, for example. There's nothing in our test setup that would prohibit this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/geis/geis.h'
2--- include/geis/geis.h 2012-04-18 19:00:07 +0000
3+++ include/geis/geis.h 2012-04-19 13:32:20 +0000
4@@ -630,7 +630,7 @@
5 * If no initialization arguments are passed, the parameter list consists of a
6 * single NULL argument.
7 */
8-GEIS_API Geis geis_new(GeisString init_arg_name, ...);
9+GEIS_API GEIS_VARARG Geis geis_new(GeisString init_arg_name, ...);
10
11 /**
12 * Cleans up an instance of the GEIS v2.0 API.
13@@ -1656,9 +1656,9 @@
14 *
15 * @returns a newly created region, or NULL on failure.
16 */
17-GEIS_API GeisRegion geis_region_new(Geis geis,
18- GeisString name,
19- GeisString init_arg_name, ...);
20+GEIS_API GEIS_VARARG GeisRegion geis_region_new(Geis geis,
21+ GeisString name,
22+ GeisString init_arg_name, ...);
23
24 /**
25 * Destroys a GEIS v2.0 region.
26@@ -1787,9 +1787,9 @@
27 * NULL);
28 * @endcode
29 */
30-GEIS_API GeisStatus geis_filter_add_term(GeisFilter filter,
31- GeisFilterFacility facility,
32- ...);
33+GEIS_API GEIS_VARARG GeisStatus geis_filter_add_term(GeisFilter filter,
34+ GeisFilterFacility facility,
35+ ...);
36
37 /* @} */
38
39
40=== modified file 'libutouch-geis/geis/geisimpl.h'
41--- libutouch-geis/geis/geisimpl.h 2010-12-20 18:06:36 +0000
42+++ libutouch-geis/geis/geisimpl.h 2012-04-19 13:32:20 +0000
43@@ -23,6 +23,7 @@
44 #include <stdint.h>
45 #include <stdlib.h>
46
47+/* Provide some cross-platform symbol export decorations. */
48 #if defined _WIN32 || defined __CYGWIN__
49 #define GEIS_HELPER_DSO_IMPORT __declspec(dllimport)
50 #define GEIS_HELPER_DSO_EXPORT __declspec(dllexport)
51@@ -51,6 +52,13 @@
52 #define GEIS_LOCAL
53 #endif /* GEIS_BUILDING_DSO */
54
55+/* If available, provide a NULL terminator check decoration. */
56+#if __GNUC__ >= 4
57+# define GEIS_VARARG __attribute__((sentinel(0)))
58+#else
59+# define GEIS_VARARG
60+#endif
61+
62 /**
63 * Portability types
64 */

Subscribers

People subscribed via source and target branches