Skip to content

Commit 8f4d955

Browse files
philmdvivier
authored andcommitted
util/qemu-option: Document the get_opt_value() function
Coverity noticed commit 950c4e6 introduced a dereference before null check in get_opt_value (CID1391003): In get_opt_value: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476) We fixed this in commit 6e3ad3f, but relaxed the check in commit 0c2f6e7 because "No callers of get_opt_value() pass in a NULL for the 'value' parameter". Since this function is publicly exposed, it risks new users to do the same error again. Avoid that documenting the 'value' argument must not be NULL. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent 428a377 commit 8f4d955

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/qemu/option.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828

2929
#include "qemu/queue.h"
3030

31+
/**
32+
* get_opt_value
33+
* @p: a pointer to the option name, delimited by commas
34+
* @value: a non-NULL pointer that will received the delimited options
35+
*
36+
* The @value char pointer will be allocated and filled with
37+
* the delimited options.
38+
*
39+
* Returns the position of the comma delimiter/zero byte after the
40+
* option name in @p.
41+
* The memory pointer in @value must be released with a call to g_free()
42+
* when no longer required.
43+
*/
3144
const char *get_opt_value(const char *p, char **value);
3245

3346
void parse_option_size(const char *name, const char *value,

0 commit comments

Comments
 (0)