[linux-next:master 4567/12845] kernel/trace/trace_events_user.c:424:22: warning: Pointer addition with NULL pointer. [nullPointerArithmetic]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   a32cd981a6da2373c093d471ee4405a915e217d5
commit: aa3b2b4c669205200615dd8a2cc4af4f81fd0335 [4567/12845] user_events: Add print_fmt generation support for basic types
compiler: arc-elf-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


cppcheck warnings: (new ones prefixed by >>)
>> kernel/trace/trace_events_user.c:424:22: warning: Pointer addition with NULL pointer. [nullPointerArithmetic]
    pos += snprintf(buf + pos, LEN_OR_ZERO, """);
                        ^
   kernel/trace/trace_events_user.c:456:39: note: Calling function 'user_event_set_print_fmt', 2nd argument 'NULL' value is 0
    len = user_event_set_print_fmt(user, NULL, 0);
                                         ^
   kernel/trace/trace_events_user.c:424:22: note: Null pointer addition
    pos += snprintf(buf + pos, LEN_OR_ZERO, """);
                        ^
   kernel/trace/trace_events_user.c:436:22: warning: Pointer addition with NULL pointer. [nullPointerArithmetic]
    pos += snprintf(buf + pos, LEN_OR_ZERO, """);
                        ^
   kernel/trace/trace_events_user.c:456:39: note: Calling function 'user_event_set_print_fmt', 2nd argument 'NULL' value is 0
    len = user_event_set_print_fmt(user, NULL, 0);
                                         ^
   kernel/trace/trace_events_user.c:436:22: note: Null pointer addition
    pos += snprintf(buf + pos, LEN_OR_ZERO, """);
                        ^

vim +424 kernel/trace/trace_events_user.c

   415	
   416	#define LEN_OR_ZERO (len ? len - pos : 0)
   417	static int user_event_set_print_fmt(struct user_event *user, char *buf, int len)
   418	{
   419		struct ftrace_event_field *field, *next;
   420		struct list_head *head = &user->fields;
   421		int pos = 0, depth = 0;
   422		const char *str_func;
   423	
 > 424		pos += snprintf(buf + pos, LEN_OR_ZERO, "\"");
   425	
   426		list_for_each_entry_safe_reverse(field, next, head, link) {
   427			if (depth != 0)
   428				pos += snprintf(buf + pos, LEN_OR_ZERO, " ");
   429	
   430			pos += snprintf(buf + pos, LEN_OR_ZERO, "%s=%s",
   431					field->name, user_field_format(field->type));
   432	
   433			depth++;
   434		}
   435	
   436		pos += snprintf(buf + pos, LEN_OR_ZERO, "\"");
   437	
   438		list_for_each_entry_safe_reverse(field, next, head, link) {
   439			if (user_field_is_dyn_string(field->type, &str_func))
   440				pos += snprintf(buf + pos, LEN_OR_ZERO,
   441						", %s(%s)", str_func, field->name);
   442			else
   443				pos += snprintf(buf + pos, LEN_OR_ZERO,
   444						", REC->%s", field->name);
   445		}
   446	
   447		return pos + 1;
   448	}
   449	#undef LEN_OR_ZERO
   450	

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux