Code quality: Fix some cppcheck messages
This commit addresses these kind of errors: portability: Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. [varFuncNullUB] Reason is that C does not guarantee that all pointer types are the same size. See C99 6.2.5(27). cppcheck requires some sort of cast when NULL is used as the last argument in a variadic list.
This commit is contained in:
+1
-1
@@ -271,7 +271,7 @@ list_add_strdup_multi(struct list *self, ...)
|
||||
int rv = 1;
|
||||
|
||||
va_start(ap, self);
|
||||
while ((s = va_arg(ap, const char *)) != NULL)
|
||||
while ((s = va_arg(ap, const char *)) != LIST_ADD_STRDUP_TERM)
|
||||
{
|
||||
if (!list_add_strdup(self, s))
|
||||
{
|
||||
|
||||
+5
-1
@@ -149,12 +149,16 @@ list_add_strdup(struct list *self, const char *str);
|
||||
*
|
||||
* This is a convenience function for a common operation
|
||||
* @param self List to append to
|
||||
* @param ... Strings to append. Terminate the list with a NULL.
|
||||
* @param ... Strings to append. Terminate the list with LIST_ADD_STRDUP_TERM
|
||||
*
|
||||
* @result 0 if any memory allocation failure occurred. In this case
|
||||
* the list is unchanged.
|
||||
*/
|
||||
|
||||
/*
|
||||
* We need a typed terminator to guarantee the stack object is the
|
||||
* correct size (cf C99 std 6.2.5(12) for static checkers */
|
||||
#define LIST_ADD_STRDUP_TERM ((const char *)0)
|
||||
int
|
||||
list_add_strdup_multi(struct list *self, ...);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user