forked from mirrors/linux
		
	The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
        int stuff;
        struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Link: https://lore.kernel.org/r/20200220132017.GA29262@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
		
	
			
		
			
				
	
	
		
			81 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0+
 | 
						|
/*****************************************************************************/
 | 
						|
 | 
						|
/*
 | 
						|
 *	usbdevice_fs.h  --  USB device file system.
 | 
						|
 *
 | 
						|
 *	Copyright (C) 2000
 | 
						|
 *          Thomas Sailer (sailer@ife.ee.ethz.ch)
 | 
						|
 *
 | 
						|
 *	This program is free software; you can redistribute it and/or modify
 | 
						|
 *	it under the terms of the GNU General Public License as published by
 | 
						|
 *	the Free Software Foundation; either version 2 of the License, or
 | 
						|
 *	(at your option) any later version.
 | 
						|
 *
 | 
						|
 *	This program is distributed in the hope that it will be useful,
 | 
						|
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
 *	GNU General Public License for more details.
 | 
						|
 *
 | 
						|
 *	You should have received a copy of the GNU General Public License
 | 
						|
 *	along with this program; if not, write to the Free Software
 | 
						|
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
						|
 *
 | 
						|
 *  History:
 | 
						|
 *   0.1  04.01.2000  Created
 | 
						|
 */
 | 
						|
 | 
						|
/*****************************************************************************/
 | 
						|
#ifndef _LINUX_USBDEVICE_FS_H
 | 
						|
#define _LINUX_USBDEVICE_FS_H
 | 
						|
 | 
						|
#include <uapi/linux/usbdevice_fs.h>
 | 
						|
 | 
						|
#ifdef CONFIG_COMPAT
 | 
						|
#include <linux/compat.h>
 | 
						|
 | 
						|
struct usbdevfs_ctrltransfer32 {
 | 
						|
        u8 bRequestType;
 | 
						|
        u8 bRequest;
 | 
						|
        u16 wValue;
 | 
						|
        u16 wIndex;
 | 
						|
        u16 wLength;
 | 
						|
        u32 timeout;  /* in milliseconds */
 | 
						|
        compat_caddr_t data;
 | 
						|
};
 | 
						|
 | 
						|
struct usbdevfs_bulktransfer32 {
 | 
						|
        compat_uint_t ep;
 | 
						|
        compat_uint_t len;
 | 
						|
        compat_uint_t timeout; /* in milliseconds */
 | 
						|
        compat_caddr_t data;
 | 
						|
};
 | 
						|
 | 
						|
struct usbdevfs_disconnectsignal32 {
 | 
						|
        compat_int_t signr;
 | 
						|
        compat_caddr_t context;
 | 
						|
};
 | 
						|
 | 
						|
struct usbdevfs_urb32 {
 | 
						|
	unsigned char type;
 | 
						|
	unsigned char endpoint;
 | 
						|
	compat_int_t status;
 | 
						|
	compat_uint_t flags;
 | 
						|
	compat_caddr_t buffer;
 | 
						|
	compat_int_t buffer_length;
 | 
						|
	compat_int_t actual_length;
 | 
						|
	compat_int_t start_frame;
 | 
						|
	compat_int_t number_of_packets;
 | 
						|
	compat_int_t error_count;
 | 
						|
	compat_uint_t signr;
 | 
						|
	compat_caddr_t usercontext; /* unused */
 | 
						|
	struct usbdevfs_iso_packet_desc iso_frame_desc[];
 | 
						|
};
 | 
						|
 | 
						|
struct usbdevfs_ioctl32 {
 | 
						|
	s32 ifno;
 | 
						|
	s32 ioctl_code;
 | 
						|
	compat_caddr_t data;
 | 
						|
};
 | 
						|
#endif
 | 
						|
#endif /* _LINUX_USBDEVICE_FS_H */
 |