Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#CCCCFF
borderStylesolid
#include <stddef.h>

struct test{
 int  int a;
  char b;
  int c;
} __attribute__((__packed__));

/* ... 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};

  /* ..
.
// perform operationoperations on arg
.
.
// Copy ... */

  /* copy arg to user space */
  copy_to_user(ptrusr_buf, &arg, sizeof(arg));

 /* ... */
}

Compliant Solution 2(Structure Packing - MSVC)

...