golioth / golioth-zephyr-sdk

Golioth SDK For Zephyr
https://www.golioth.io
Apache License 2.0
68 stars 19 forks source link

golioth: coap_utils: new helper module #265

Closed mniestroj closed 2 years ago

mniestroj commented 2 years ago

This private module will be used by updated lightdb and fw components.

github-actions[bot] commented 2 years ago

Visit the preview URL for this PR (updated for commit 19132c7):

https://golioth-zephyr-sdk-doxygen-dev--pr265-coap-utils-87oefh5v.web.app

(expires Thu, 08 Sep 2022 12:00:12 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

mniestroj commented 2 years ago

I believe that checkpatch warning is a false-positive:

389a471d9d3d9ca74371d338c1419ba976c4e381:41: CHECK:MACRO_ARG_PRECEDENCE: Macro argument '_name' may be better as '(_name)' to avoid precedence issues
#41: FILE: net/golioth/pathv.h:6:
+#define PATHV(_name, ...)              \
+   const uint8_t *_name[] = {          \
+       FOR_EACH(IDENTITY, (,), __VA_ARGS__),   \
+       NULL, /* sentinel */            \
+   }
mniestroj commented 2 years ago

@ncmiller Please take another look at the PATHV() definition. I decided to use "anonymous compound literals" as I have run into such code in Zephyr CTF (common tracing format) implementation. Seems to be a standard starting with C99, so safe to use here. This allows to use PATHV() directly in function invocation as opposed to declaring temporary variable explicitly in function body.