Skip to content

eBPF-based security platform

util: make the time, location and key algorithm formatters __must_check

Daniel Borkmann1cd9677f90c0
diff --git a/builtin-keys.c b/builtin-keys.c
index b7894812..e3903894 100644
--- a/builtin-keys.c
+++ b/builtin-keys.c
@@ -169,7 +169,8 @@ static void print_fpr(const char *label, const __u8 *fpr)
* provider's own name ("ML-DSA-87"), whose parameter set already says
* everything a bit count would.
*/
-static int format_pkey_algorithm(EVP_PKEY *pkey, char *out, size_t out_sz)
+static __must_check int format_pkey_algorithm(EVP_PKEY *pkey, char *out,
+ size_t out_sz)
{
const char *name = EVP_PKEY_get0_type_name(pkey);
int id = EVP_PKEY_get_base_id(pkey);
diff --git a/util/timefmt.h b/util/timefmt.h
index c3c76576..b014415f 100644
--- a/util/timefmt.h
+++ b/util/timefmt.h
@@ -11,10 +11,12 @@
#include <stddef.h>
#include <time.h>
-/* A negative seconds writes "?"; cap must hold the worst-case %ldd. */
-int format_duration(long seconds, char *buf, size_t cap);
+#include <shirudo/compiler.h>
+
+/* A negative seconds writes "?"; -E2BIG, buf empty, when it does not fit. */
+int format_duration(long seconds, char *buf, size_t cap) __must_check;
/* UTC to the second; "" and -EINVAL when t cannot be rendered. */
-int iso8601(time_t t, char *out, size_t cap);
+int iso8601(time_t t, char *out, size_t cap) __must_check;
#endif /* SHIRUDO_TIMEFMT_H */
diff --git a/util/upatch_resolve.h b/util/upatch_resolve.h
index 19ffe84d..31be9ba8 100644
--- a/util/upatch_resolve.h
+++ b/util/upatch_resolve.h
@@ -11,6 +11,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include <shirudo/compiler.h>
#include <shirudo/types.h>
struct bpf_link_info;
@@ -37,9 +38,12 @@ int upatch_each_link_info(const char *name,
/* From the first link, or from an XDP program pin when it has none. */
int upatch_first_prog_id(const char *name, __u32 *out);
-/* vbtf may be NULL; the location then degrades to the bare prefix. */
+/*
+ * vbtf may be NULL; the location then degrades to the bare prefix. On
+ * failure out is empty.
+ */
int upatch_resolve_location(struct btf *vbtf, const char *name,
- char *out, size_t cap);
+ char *out, size_t cap) __must_check;
/*
* The runs the kernel skipped of one program of an upatch: the program's