From: Uri Simchoni Date: Wed, 22 Nov 2017 20:48:23 +0000 (+0000) Subject: pam_wrapper: Use a constant string format specifier in test X-Git-Tag: talloc-2.1.11~386 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4fc4e41760af91fb1fa28f6a9a8b1ee7e4d47dbc;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andreas Schneider Reviewed-by: Andrew Bartlett (ported from pam_wrapper 9265da3857e9cfa7a00d1ab35aae1e0b0286efad) --- diff --git a/lib/pam_wrapper/python/pypamtest.c b/lib/pam_wrapper/python/pypamtest.c index c52e1bce685..e25900f001b 100644 --- a/lib/pam_wrapper/python/pypamtest.c +++ b/lib/pam_wrapper/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);