diff --git a/libraries/libapparmor/swig/SWIG/libapparmor.i b/libraries/libapparmor/swig/SWIG/libapparmor.i index 029fafdd7..9c01b182b 100644 --- a/libraries/libapparmor/swig/SWIG/libapparmor.i +++ b/libraries/libapparmor/swig/SWIG/libapparmor.i @@ -258,7 +258,13 @@ extern int aa_is_enabled(void); * allocation uninitialized (0) != SWIG_NEWOBJ */ %#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - static_assert(SWIG_NEWOBJ != 0); + /* + * Some older versions of SWIG place this right after a goto label + * This would then be a label followed by a declaration, a C23 extension (!) + * To ensure this works for older SWIG versions and older compilers, + * make this a block element with curly braces. + */ + {static_assert(SWIG_NEWOBJ != 0, "SWIG_NEWOBJ is 0");} %#endif if ($1 != NULL && alloc_tracking$argnum != NULL) { for (Py_ssize_t i=0; i sizeof(long) then aalogparse + * itself would also need fixing. */ -%typemap(in,noblock=1,fragment="SWIG_AsVal_long") pid_t (int conv_pid, intmax_t pid_large) { +%typemap(in,noblock=1,fragment="SWIG_AsVal_long") pid_t (int conv_pid, long pid_large) { +%#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + static_assert(sizeof(pid_t) <= sizeof(long), + "pid_t type is too large to be stored in a long"); +%#endif conv_pid = SWIG_AsVal_long($input, &pid_large); if (!SWIG_IsOK(conv_pid)) { %argument_fail(conv_pid, "pid_t", $symname, $argnum); @@ -328,7 +341,7 @@ extern int aa_stack_onexec(const char *profile); * Technically this is implementation-defined behaviour but we should be fine */ $1 = (pid_t) pid_large; - if ((intmax_t) $1 != pid_large) { + if ((long) $1 != pid_large) { SWIG_exception_fail(SWIG_OverflowError, "pid_t is too large"); } }