Skip to contentSkip to conversation

Correct ELL header errors included C++ code.

PATCH Superseded Ossama Othman 2 participants 4 messages Jan 23, 2019 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Correct ELL header errors included C++ code.

Including <ell/ell.h> in C++ code revealed a few C++ related conflicts in <ell/key.h>. These patches address those errors, and add a simple C++ build test that enabled if a C++ compiler is found when maintainer mode is enabled.

Ossama Othman (2):
key: Avoid using C++ keywords as param names.
unit: Added a minimal C++ build test.

 .gitignore              |  1 +
 Makefile.am             |  6 ++++++
 configure.ac            |  3 +++
 ell/key.h               |  6 +++---
 unit/test-cxx-build.cpp | 42 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 55 insertions(+), 3 deletions(-)
 create mode 100644 unit/test-cxx-build.cpp
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 key: Avoid using C++ keywords as param names.

Rename the parameter names "public" and "private" to avoid conflicts with the similarly named C++ keywords. Addresses compile-time errors in C++ code that includes <ell/key.h>.

---
 ell/key.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
ell/key.h +3 -3
index 024afc6..0107b05 100644
@@ -70,16 +70,16 @@ ssize_t l_key_get_payload_size(struct l_key *key);
 
 bool l_key_get_info(struct l_key *key, enum l_key_cipher_type cipher,
 			enum l_checksum_type checksum, size_t *bits,
-			bool *public);
+			bool *_public);
 
 struct l_key *l_key_generate_dh_private(const void *prime_buf,
 					size_t prime_len);
 
-bool l_key_compute_dh_public(struct l_key *generator, struct l_key *private,
+bool l_key_compute_dh_public(struct l_key *generator, struct l_key *_private,
 				struct l_key *prime,
 				void *payload, size_t *len);
 
-bool l_key_compute_dh_secret(struct l_key *other_public, struct l_key *private,
+bool l_key_compute_dh_secret(struct l_key *other_public, struct l_key *_private,
 				struct l_key *prime,
 				void *payload, size_t *len);
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH 2/2 unit: Added a minimal C++ build test.

In reply to Ossama Othman
---
 .gitignore              |  1 +
 Makefile.am             |  6 ++++++
 configure.ac            |  3 +++
 unit/test-cxx-build.cpp | 42 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)
 create mode 100644 unit/test-cxx-build.cpp
.gitignore +1 -0
index 75ab7b2..f10c973 100644
@@ -58,6 +58,7 @@ unit/test-dhcp
 unit/test-dir-watch
 unit/test-ecc
 unit/test-ecdh
+unit/test-cxx-build
 unit/cert-*.pem
 unit/cert-*.csr
 unit/cert-*.srl
Makefile.am +6 -0
index 3eecbe0..e7da974 100644
@@ -292,6 +292,12 @@ unit_test_ecc_LDADD = ell/libell-private.la
 unit_test_ecdh_LDADD = ell/libell-private.la
 unit_test_ecdh_LDFLAGS = -Wl,-wrap,l_getrandom
 
+if HAVE_CXX
+unit_tests += unit/test-cxx-build
+unit_test_cxx_build_SOURCES = unit/test-cxx-build.cpp
+unit_test_cxx_build_LDADD = ell/libell-private.la
+endif
+
 if MAINTAINER_MODE
 noinst_LTLIBRARIES += unit/example-plugin.la
 endif
configure.ac +3 -0
index 1eeebec..f2d1c4f 100644
@@ -125,6 +125,9 @@ fi
 AM_CONDITIONAL(GLIB, test "${enable_glib}" = "yes")
 
 if (test "$USE_MAINTAINER_MODE" = "yes"); then
+	AC_PROG_CXX
+	AM_CONDITIONAL([HAVE_CXX], [test -n "$CXX"])
+
 	AC_CHECK_PROG(have_openssl, [openssl], [yes], [no])
 	AC_CHECK_PROG(have_xxd, [xxd], [yes], [no])
 fi
unit/test-cxx-build.cpp new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/2] key: Avoid using C++ keywords as param names.

In reply to Ossama Othman

Hi Ossama,

Quoted 3 lines · Ossama Othman

Rename the parameter names "public" and "private" to avoid conflicts with the similarly named C++ keywords. Addresses compile-time errors in C++ code that includes <ell/key.h>.

Ugh... Are you seriously using ell in a C++ application? ;)

Quoted 9 lines
---
  ell/key.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
ell/key.h +0 -0
index 024afc6..0107b05 100644

ell/key.h ssize_t l_key_get_payload_size(struct l_key *key); · line 73

Quoted 5 lines
ell/key.h +1 -1
@@ -70,16 +70,16 @@ ssize_t l_key_get_payload_size(struct l_key *key);
 
  bool l_key_get_info(struct l_key *key, enum l_key_cipher_type cipher,
  			enum l_checksum_type checksum, size_t *bits,
-			bool *public);
+			bool *_public);

out_public please

ell/key.h ssize_t l_key_get_payload_size(struct l_key *key); · line 78

Quoted 6 lines
ell/key.h +1 -1
  struct l_key *l_key_generate_dh_private(const void *prime_buf,
  					size_t prime_len);
 
-bool l_key_compute_dh_public(struct l_key *generator, struct l_key *private,
+bool l_key_compute_dh_public(struct l_key *generator, struct l_key *_private,

And just call this private_key or private_secret

ell/key.h ssize_t l_key_get_payload_size(struct l_key *key); · line 85

Quoted 8 lines
ell/key.h +1 -1
  				struct l_key *prime,
  				void *payload, size_t *len);
 
-bool l_key_compute_dh_secret(struct l_key *other_public, struct l_key *private,
+bool l_key_compute_dh_secret(struct l_key *other_public, struct l_key *_private,
  				struct l_key *prime,
  				void *payload, size_t *len);
 

As above.

Quoted 1 line

Regards,
-Denis