diff mbox series

[RFC] build: Move autodestruct macro definition

Message ID 20240201162000.913015-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [RFC] build: Move autodestruct macro definition | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/crypto.c: In function ‘crypto_derive_sae_pt_ecc’: ../../src/crypto.c:1156:9: warning: implicit declaration of function ‘_auto_’ [-Wimplicit-function-declaration] 1156 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; | ^~~~~~ ../../src/crypto.c:1156:34: error: expected ‘;’ before ‘struct’ 1156 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; | ^~~~~~~ | ; ../../src/crypto.c:1157:34: error: expected ‘;’ before ‘struct’ 1157 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u2 = NULL; | ^~~~~~~ | ; ../../src/crypto.c:1158:33: error: expected ‘;’ before ‘struct’ 1158 | _auto_(l_ecc_point_free) struct l_ecc_point *p1 = NULL; | ^~~~~~~ | ; ../../src/crypto.c:1159:33: error: expected ‘;’ before ‘struct’ 1159 | _auto_(l_ecc_point_free) struct l_ecc_point *p2 = NULL; | ^~~~~~~ | ; ../../src/crypto.c:1160:33: error: expected ‘;’ before ‘struct’ 1160 | _auto_(l_ecc_point_free) struct l_ecc_point *pt = NULL; | ^~~~~~~ | ; ../../src/crypto.c:1183:9: error: ‘u1’ undeclared (first use in this function) 1183 | u1 = l_ecc_scalar_new_modp(curve, pwd_value, pwd_value_len); | ^~ ../../src/crypto.c:1183:9: note: each undeclared identifier is reported only once for each function it appears in ../../src/crypto.c:1190:9: error: ‘u2’ undeclared (first use in this function) 1190 | u2 = l_ecc_scalar_new_modp(curve, pwd_value, pwd_value_len); | ^~ ../../src/crypto.c:1192:9: error: ‘p1’ undeclared (first use in this function) 1192 | p1 = l_ecc_point_from_sswu(u1); | ^~ ../../src/crypto.c:1193:9: error: ‘p2’ undeclared (first use in this function) 1193 | p2 = l_ecc_point_from_sswu(u2); | ^~ ../../src/crypto.c:1195:9: error: ‘pt’ undeclared (first use in this function) 1195 | pt = l_ecc_point_new(curve); | ^~ In file included from ./ell/ell.h:1, from ../../src/crypto.c:34: ../../ell/util.h:238:25: warning: returning ‘int’ from a function with return type ‘struct l_ecc_point *’ makes pointer from integer without a cast [-Wint-conversion] 238 | (__extension__ ({ typeof(ptr) _tmp = (ptr); (ptr) = NULL; _tmp; })) | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/crypto.c:1198:16: note: in expansion of macro ‘l_steal_ptr’ 1198 | return l_steal_ptr(pt); | ^~~~~~~~~~~ make[2]: *** [Makefile:2540: src/crypto.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1714: all] Error 2 make: *** [Makefile:3317: distcheck] Error 1
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: src/crypto.c: In function ‘crypto_derive_sae_pt_ecc’: src/crypto.c:1156:9: error: implicit declaration of function ‘_auto_’ [-Werror=implicit-function-declaration] 1156 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; | ^~~~~~ src/crypto.c:1156:34: error: expected ‘;’ before ‘struct’ 1156 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; | ^~~~~~~ | ; src/crypto.c:1157:34: error: expected ‘;’ before ‘struct’ 1157 | _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u2 = NULL; | ^~~~~~~ | ; src/crypto.c:1158:33: error: expected ‘;’ before ‘struct’ 1158 | _auto_(l_ecc_point_free) struct l_ecc_point *p1 = NULL; | ^~~~~~~ | ; src/crypto.c:1159:33: error: expected ‘;’ before ‘struct’ 1159 | _auto_(l_ecc_point_free) struct l_ecc_point *p2 = NULL; | ^~~~~~~ | ; src/crypto.c:1160:33: error: expected ‘;’ before ‘struct’ 1160 | _auto_(l_ecc_point_free) struct l_ecc_point *pt = NULL; | ^~~~~~~ | ; src/crypto.c:1183:9: error: ‘u1’ undeclared (first use in this function) 1183 | u1 = l_ecc_scalar_new_modp(curve, pwd_value, pwd_value_len); | ^~ src/crypto.c:1183:9: note: each undeclared identifier is reported only once for each function it appears in src/crypto.c:1190:9: error: ‘u2’ undeclared (first use in this function) 1190 | u2 = l_ecc_scalar_new_modp(curve, pwd_value, pwd_value_len); | ^~ src/crypto.c:1192:9: error: ‘p1’ undeclared (first use in this function) 1192 | p1 = l_ecc_point_from_sswu(u1); | ^~ src/crypto.c:1193:9: error: ‘p2’ undeclared (first use in this function) 1193 | p2 = l_ecc_point_from_sswu(u2); | ^~ src/crypto.c:1195:9: error: ‘pt’ undeclared (first use in this function) 1195 | pt = l_ecc_point_new(curve); | ^~ In file included from ./ell/ell.h:1, from src/crypto.c:34: ./ell/util.h:238:25: error: returning ‘int’ from a function with return type ‘struct l_ecc_point *’ makes pointer from integer without a cast [-Werror=int-conversion] 238 | (__extension__ ({ typeof(ptr) _tmp = (ptr); (ptr) = NULL; _tmp; })) | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/crypto.c:1198:16: note: in expansion of macro ‘l_steal_ptr’ 1198 | return l_steal_ptr(pt); | ^~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2540: src/crypto.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1714: all] Error 2
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: src/crypto.c:1156:2: error: implicit declaration of function '_auto_' is invalid in C99 [-Werror,-Wimplicit-function-declaration] _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; ^ src/crypto.c:1156:27: error: expected ';' after expression _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; ^ ; src/crypto.c:1157:27: error: expected ';' after expression _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u2 = NULL; ^ ; src/crypto.c:1158:26: error: expected ';' after expression _auto_(l_ecc_point_free) struct l_ecc_point *p1 = NULL; ^ ; src/crypto.c:1159:26: error: expected ';' after expression _auto_(l_ecc_point_free) struct l_ecc_point *p2 = NULL; ^ ; src/crypto.c:1160:26: error: expected ';' after expression _auto_(l_ecc_point_free) struct l_ecc_point *pt = NULL; ^ ; src/crypto.c:1156:49: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] _auto_(l_ecc_scalar_free) struct l_ecc_scalar *u1 = NULL; ^ 7 errors generated. make[1]: *** [Makefile:2540: src/crypto.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1714: all] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-ci-makecheck pending makecheck SKIP

Commit Message

Denis Kenzior Feb. 1, 2024, 4:19 p.m. UTC
_auto_ syntax is widely used by ell and iwd, however it isn't part of
the public ell API.  Currently it is defined in ell/useful.h, but this
header isn't distributed with other public ell headers.  iwd has special
hacks in its build system to enable use of useful.h, but this may not be
sustainable if multiple ell based projects would like to use this
facility.

Move the _auto_ macro definition out of useful.h and into the build
system.  Any project can thus enable the _auto_ syntax by adding a 1
liner to 'configure.ac'
---
 configure.ac | 2 ++
 ell/useful.h | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 0dd569570a75..8d88f1c2a022 100644
--- a/configure.ac
+++ b/configure.ac
@@ -150,4 +150,6 @@  AC_SUBST(OPENSSL_PROVIDER)
 
 AC_CONFIG_FILES(Makefile ell/ell.pc)
 
+AC_DEFINE([_auto_], [__L_AUTODESTRUCT], [autodestruct syntax])
+
 AC_OUTPUT
diff --git a/ell/useful.h b/ell/useful.h
index ab88f52556f5..a3d5ad916bd8 100644
--- a/ell/useful.h
+++ b/ell/useful.h
@@ -59,9 +59,6 @@  static inline unsigned char bit_field(const unsigned char oct,
 	_x / _d;					\
 })
 
-#define _auto_(func)					\
-	__L_AUTODESTRUCT(func)
-
 /*
  * Trick the compiler into thinking that var might be changed somehow by
  * the asm