[PATCHES] pam_wrapper: fix some clang/FreeBSD picky-developer warnings
Uri Simchoni
uri at samba.org
Wed Nov 22 21:24:08 UTC 2017
Hi,
This patch set contains patches for upstream pam_wrapper, concerning
fixes to FreeBSD picky-developer build. An accompanying patch has been
reviewed and fixed by Andreas already.
About the conversion from a variable to a macro - yes that's contrary to
what they teach us (particularly in C++ school), but one has to remember
that the reason for deprecation of macros is that tools don't handle
them intelligently - well, here's a case where at least a particular
compiler handles macros more intelligently than a variable... (tried
const without the static - in C++ that should have done the trick, no
luck either :( )
Please review and maybe push...
Thanks,
Uri.
-------------- next part --------------
From ac3888de82c338b8b6085008d52a6ba8578b008b Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 19 Nov 2017 13:08:30 +0000
Subject: [PATCH 1/2] pam_wrapper: use uintptr_t as base for const-discarding
Seems like HAVE_INTPTR_T is not available on FreeBSD. Use
the uintptr_t-base const discarding to avoid picky compiler
warnings (other places in Samba also use uintptr_t).
Signed-off-by: Uri Simchoni <uri at samba.org>
---
src/python/pypamtest.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/python/pypamtest.c b/src/python/pypamtest.c
index a71fd35..c52e1bc 100644
--- a/src/python/pypamtest.c
+++ b/src/python/pypamtest.c
@@ -24,8 +24,8 @@
#define PYTHON_MODULE_NAME "pypamtest"
#ifndef discard_const_p
-#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
-# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr)))
+#if defined(__intptr_t_defined) || defined(HAVE_UINTPTR_T)
+# define discard_const_p(type, ptr) ((type *)((uintptr_t)(ptr)))
#else
# define discard_const_p(type, ptr) ((type *)(ptr))
#endif
--
2.9.5
From c391f35f59dc3319a84b75852565fb62d5c8647b Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Wed, 22 Nov 2017 20:48:23 +0000
Subject: [PATCH 2/2] pam_wrapper: use a constant string format specifier in
test
This fixes a warning about non-constant format specifier.
clang 4.0.0 warns against non-constant format specifier since
it cannot validate the format against the parameters.
Signed-off-by: Uri Simchoni <uri at samba.org>
---
src/python/pypamtest.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/python/pypamtest.c b/src/python/pypamtest.c
index c52e1bc..e25900f 100644
--- a/src/python/pypamtest.c
+++ b/src/python/pypamtest.c
@@ -67,9 +67,9 @@ static PyObject *PyExc_PamTestError;
*** helper functions
**********************************************************/
-static const char *repr_fmt = "{ pam_operation [%d] "
- "expected_rv [%d] "
- "flags [%d] }";
+#define REPR_FMT "{ pam_operation [%d] " \
+ "expected_rv [%d] " \
+ "flags [%d] }"
static char *py_strdup(const char *string)
{
@@ -267,7 +267,7 @@ set_pypamtest_exception(PyObject *exc,
size_t num_tests)
{
PyObject *obj = NULL;
- /* repr_fmt is fixed and contains just %d expansions, so this is safe */
+ /* REPR_FMT contains just %d expansions, so this is safe */
char test_repr[256] = { '\0' };
union {
char *str;
@@ -286,7 +286,7 @@ set_pypamtest_exception(PyObject *exc,
if (perr == PAMTEST_ERR_CASE) {
failed = _pamtest_failed_case(tests, num_tests);
if (failed) {
- snprintf(test_repr, sizeof(test_repr), repr_fmt,
+ snprintf(test_repr, sizeof(test_repr), REPR_FMT,
failed->pam_operation,
failed->expected_rv,
failed->flags);
@@ -422,7 +422,7 @@ static int TestCase_init(TestCaseObject *self,
*/
static PyObject *TestCase_repr(TestCaseObject *self)
{
- return PyUnicode_FromFormat(repr_fmt,
+ return PyUnicode_FromFormat(REPR_FMT,
self->pam_operation,
self->expected_rv,
self->flags);
--
2.9.5
More information about the samba-technical
mailing list