This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C Code mutilation by using gcc-3.3.x


Hello,

I write this email not by accident. I have emailed the below example to
several people and without exception stated that whats happening here 
is a bad thing. Here follows :

The below header and Makefile are being used to compile the ft3xx.o fasttrak
kernel module to get the Promise FastTrak TX4000 IDE-RAID controller to work 
together with Linux kernel 2.4.2x :

Makefile :
----------
/***********************************************************************
*   PROMISE FastTrak TX4000/376/378/S150 TX Series Linux Driver README *
*                                                                      *
*   PROMISE Linux support team <support@promise.com.tw>   2003/07/03   *
***********************************************************************/

How to make and load a Driver module (UP/SMP) for FastTrak

1.) Make sure you have linux kernel source code in /usr/src/linux,
    and the gcc version is 3.x by issuing the command -
    # gcc -v


fasttrak.h :
------------
/********************************************************************* 
  
   fasttrak.h -- PROMISE FastTrak Controllers device driver for Linux.

   Copyright (C) 2002-2005 PROMISE Technology, Inc.

   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; version 2 of the License.

   Bugs/Comments/Suggestions should be mailed to:                            
   support@promise.com.tw

   For more information, goto:
   http://www.promise.com

*********************************************************************/

#ifndef _ft3xx_h
#define _ft3xx_h

#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#define ft3xx {							\
	next: NULL,						\
	proc_dir: NULL, 					\
	proc_info: NULL,    				        \
	name: "ft3xx",						\
	detect: ft3xx_detect,					\
	release: ft3xx_release,					\
	ioctl: ft3xx_ioctl,					\
	info: NULL,					        \
	command: NULL,						\
	queuecommand: ft3xx_queuecommand,			\
	eh_abort_handler : ft3xx_abort_eh,			\
	eh_device_reset_handler : ft3xx_reset_eh,		\
	abort: ft3xx_abort,					\
	reset: ft3xx_reset,					\
	slave_attach: NULL,					\
	bios_param: ft3xx_bios_param,				\
	can_queue: Can_Queue,	/* max simultaneous cmds      */\
	this_id: 7,		/* scsi id of host adapter    */\
	sg_tablesize: Max_SG_Table - 2,/* max scatter-gather cmds    */\
	cmd_per_lun: 1,		/* cmds per lun (linked cmds) */\
	present: 0,						\
	unchecked_isa_dma: 0,	/* no memory DMA restrictions */\
	use_clustering: 0,					\
        use_new_eh_code: 0, 	/* enable this field next time*/\
        emulated: 0, 						\
        proc_name: "ft3xx" 					\
} 
#else
#define ft3xx {							\
	next: NULL,						\
	proc_dir: NULL, 					\
	proc_info: NULL,    				        \
	name: "ft3xx",						\
	detect: ft3xx_detect,					\
	release: ft3xx_release,					\
	ioctl: ft3xx_ioctl,					\
	info: NULL,					        \
	command: NULL,						\
	queuecommand: ft3xx_queuecommand,			\
	eh_abort_handler : ft3xx_abort_eh,			\
	eh_device_reset_handler : ft3xx_reset_eh,		\
	abort: ft3xx_abort,					\
	reset: ft3xx_reset,					\
	slave_attach: NULL,					\
	bios_param: ft3xx_bios_param,				\
	can_queue: Can_Queue,	/* max simultaneous cmds      */\
	this_id: 7,		/* scsi id of host adapter    */\
	sg_tablesize: Max_SG_Table - 2,	/* max scatter-gather cmds    */\
	cmd_per_lun: 1,		/* cmds per lun (linked cmds) */\
	present: 0,						\
	unchecked_isa_dma: 0,	/* no memory DMA restrictions */\
	use_clustering: 0,					\
        use_new_eh_code: 0, 	/* enable this field next time*/\
        emulated: 0, 						\
} 
#endif


#endif /* _ft3xx_h */ 

When trying to compile this driver source with gcc-2.95.3 instead
of gcc-3.3.1 , i get the following results :

[jackson:root]:(/home/stock/fasttrak)# make
gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i586 -nostdinc -iwithprefix include -DKBUILD_BASENAME=ft3xx -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h -D__LINUX__ -c wrapper.c 
gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i586 -nostdinc -iwithprefix include -DKBUILD_BASENAME=ft3xx -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h -D__LINUX__ -c fasttrak.c 
In file included from fasttrak.c:47:
fasttrak.h:26: parse error before `:'
fasttrak.h:26: stray '\' in program
fasttrak.h:27: stray '\' in program
fasttrak.h:28: stray '\' in program
fasttrak.h:29: stray '\' in program
fasttrak.h:30: stray '\' in program
fasttrak.h:31: stray '\' in program
fasttrak.h:32: stray '\' in program
fasttrak.h:33: stray '\' in program
fasttrak.h:34: stray '\' in program
fasttrak.h:35: stray '\' in program
fasttrak.h:36: stray '\' in program
fasttrak.h:37: stray '\' in program
fasttrak.h:38: stray '\' in program
fasttrak.h:39: stray '\' in program
fasttrak.h:40: stray '\' in program
fasttrak.h:41: stray '\' in program
fasttrak.h:42: stray '\' in program
fasttrak.h:43: stray '\' in program
fasttrak.h:44: stray '\' in program
fasttrak.h:45: stray '\' in program
fasttrak.h:46: stray '\' in program
fasttrak.h:47: stray '\' in program
fasttrak.h:48: stray '\' in program
fasttrak.h:49: stray '\' in program
fasttrak.h:50: stray '\' in program
fasttrak.h:51: stray '\' in program
fasttrak.h:85: warning: This file contains more `}'s than `{'s.
fasttrak.c:890: stray '\' in program
fasttrak.c:890: parse error before `;'
In file included from fasttrak.c:891:
/usr/src/linux/drivers/scsi/scsi_module.c:38: parse error before `)'
/usr/src/linux/drivers/scsi/scsi_module.c:42: warning: initialization from incompatible pointer type
/usr/src/linux/drivers/scsi/scsi_module.c:42: parse error before `)'
/usr/src/linux/drivers/scsi/scsi_module.c: In function `__init_module_inline':
/usr/src/linux/drivers/scsi/scsi_module.c:51: `init_this_scsi_driver' undeclared (first use in this function)
/usr/src/linux/drivers/scsi/scsi_module.c:51: (Each undeclared identifier is reported only once
/usr/src/linux/drivers/scsi/scsi_module.c:51: for each function it appears in.)
/usr/src/linux/drivers/scsi/scsi_module.c:51: warning: control reaches end of non-void function
/usr/src/linux/drivers/scsi/scsi_module.c: In function `__cleanup_module_inline':
/usr/src/linux/drivers/scsi/scsi_module.c:52: `exit_this_scsi_driver' undeclared (first use in this function)
/usr/src/linux/drivers/scsi/scsi_module.c:52: warning: control reaches end of non-void function
fasttrak.c: At top level:
fasttrak.c:130: warning: `ft3xx_ioctl' defined but not used
make: *** [fasttrak.o] Error 1
[jackson:root]:(/home/stock/fasttrak)# 

Whats going on here?

Not only does the compilation fail with gcc-2.95.3, but when reading
fasttrak.h, the variable size is _not_ given but also the variable
type is _omitted_. How strange is it that gcc-3.3.1 is perfectly happy
with this header file.

The driver kit in this example is for download on :

http://www.promise.com/support/download/download2_eng.asp?productId=104&category=driver&os=4

http://www.promise.com/support/file/driver/1_fasttrak_tx4000_partial_source_1.00.0.19.zip

The above example of the 'partial driver source' case is not a exception
here. Another striking example with malformed header files is the latest
ntfstools-1.8.4.tar.gz source, which also has been (in the gcc-3.3.x compatible alike way) mutilated.

How in earth could the Free Software Foundation and the GCC Team allowed this
to happen?

Regards,

Robert
-- 
Robert M. Stockmann - RHCE
Network Engineer - UNIX/Linux Specialist
crashrecovery.org  stock@stokkie.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]