1  typedef __SIZE_TYPE__ size_t;
       2  
       3  #define __user
       4  
       5  extern int copy_from_user(void *to, const void __user *from, long n)
       6    __attribute__((access (write_only, 1, 3),
       7  		 access (read_only, 2, 3)
       8  		 ));
       9  
      10  #define   EFAULT          14
      11  #define   EINVAL          22
      12  
      13  /* Taken from Linux: fs/binfmt_misc.c (GPL-2.0-only).  */
      14  
      15  int parse_command(const char __user *buffer, size_t count)
      16  {
      17  	char s[4];
      18  
      19  	if (count > 3)
      20  		return -EINVAL;
      21  	if (copy_from_user(s, buffer, count))
      22  		return -EFAULT;
      23  	if (!count)
      24  		return 0;
      25  	if (s[count - 1] == '\n') /* { dg-bogus "uninit" } */
      26  		count--;
      27  	if (count == 1 && s[0] == '0') /* { dg-bogus "uninit" } */
      28  		return 1;
      29  	if (count == 1 && s[0] == '1') /* { dg-bogus "uninit" } */
      30  		return 2;
      31  	if (count == 2 && s[0] == '-' && s[1] == '1') /* { dg-bogus "uninit" } */
      32  		return 3;
      33  	return -EINVAL;
      34  }
      35  
      36  /* Not using return value from copy_from_user.  */
      37  
      38  int test_2 (const char __user *buffer, size_t count)
      39  {
      40    char s[4];
      41    if (count > 3)
      42      return -EINVAL;
      43    copy_from_user(s, buffer, count);
      44    return 0;  
      45  }