diff mbox series

[ovs-dev,1/8] ovsdb-error: Annotate nonnull functions

Message ID 20240820131444.1724438-2-mkp@redhat.com
State Superseded, archived
Headers show
Series Address clang analyze warnings. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Mike Pattrick Aug. 20, 2024, 1:14 p.m. UTC
The Clang analyzer has trouble detecting that functions can never return
null in certain conditions, this results in several false "Dereference of
null pointer" detections.

This patch annotates functiosn that call ovsdb_error_valist()
unconditionally as nonnull, as this function will either return a valid
pointer or call abort().

Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 lib/ovsdb-error.h | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/lib/ovsdb-error.h b/lib/ovsdb-error.h
index 77a60e074..a63e92b15 100644
--- a/lib/ovsdb-error.h
+++ b/lib/ovsdb-error.h
@@ -20,12 +20,15 @@ 
 
 struct json;
 
+OVS_RETURNS_NONNULL
 struct ovsdb_error *ovsdb_error(const char *tag, const char *details, ...)
     OVS_PRINTF_FORMAT(2, 3)
     OVS_WARN_UNUSED_RESULT;
+OVS_RETURNS_NONNULL
 struct ovsdb_error *ovsdb_io_error(int error, const char *details, ...)
     OVS_PRINTF_FORMAT(2, 3)
     OVS_WARN_UNUSED_RESULT;
+OVS_RETURNS_NONNULL
 struct ovsdb_error *ovsdb_syntax_error(const struct json *, const char *tag,
                                        const char *details, ...)
     OVS_PRINTF_FORMAT(3, 4)
@@ -35,12 +38,14 @@  struct ovsdb_error *ovsdb_wrap_error(struct ovsdb_error *error,
                                      const char *details, ...)
     OVS_PRINTF_FORMAT(2, 3);
 
+OVS_RETURNS_NONNULL
 struct ovsdb_error *ovsdb_internal_error(struct ovsdb_error *error,
                                          const char *file, int line,
                                          const char *details, ...)
     OVS_PRINTF_FORMAT(4, 5)
     OVS_WARN_UNUSED_RESULT;
 
+OVS_RETURNS_NONNULL
 struct ovsdb_error *ovsdb_perm_error(const char *details, ...)
     OVS_PRINTF_FORMAT(1, 2)
     OVS_WARN_UNUSED_RESULT;