Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: split two NCCEs into sections

...

Code Block
bgColor#FFCCCC
langc
#include <stddef.h>

struct test{
  int a;
  char b;
  int c;
};

/* Safely copy bytes to user space */
extern int copy_to_user(void *dest, void *src, size_t size);

void do_stuff(void *usr_buf) {
  struct test arg = {.a = 1, .b = 2, .c = 3};
  copy_to_user(usr_buf, &arg, sizeof(arg));
}

Noncompliant Code Example (memset())

The padding bytes can be explicitly initialized by calling memset():

...