Skip to contentSkip to conversation

ltp: kill off some compile warnings

PATCH In review Alex Elder 2 participants 11 messages Apr 1, 2011 – Apr 8, 2011 1 message not in the archive Library code

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

cover ltp: kill off some compile warnings

The motivation for this series of patches is to eliminate build warnings in files under "testcases/kernel/fs/doio/". The main reason warnings are emitted is that most functions are defined using old-style C syntax. So most of the changes amount to updating such functions to use standard C prototypes.

The first patch fixes a buggy header file. The next one gathers type definitions to the top of "doio.c" so they are defined when needed in declaring all the function prototypes.

The last patch enables the "-Wall" flag to gcc for these files.

-Alex

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#1 lore raw

PATCH 1/6 ltp: fix databinchk() definition

Fix a bogus (misspelled) declaration for databinchk() in "include/databin.h".

Then, change databinchk() so that its second argument is a signed rather than an unsigned character pointer. This is consistent with the way it is used throughout the code. Because of the way that argument is used, it won't change the behavior of that function; its value is immediately assigned to a local variable, which is still unsigned. Add a cast in that assignment to force the conversion.

---
 include/databin.h |    2 +-
 lib/databin.c     |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/databin.h +1 -1
index c168799..93c3863 100644
@@ -39,6 +39,6 @@
 
 void databingen( int mode, char *buffer, int bsize, int offset );
 
-void databinchedk( int mode, unsigned char *buffer, int bsize, int offset, char **errmsg);
+int databinchk( int mode, char *buffer, int bsize, int offset, char **errmsg);
 
 #endif
lib/databin.c +2 -2
index 6659ccf..c0f4307 100644
@@ -91,7 +91,7 @@ int ind;
 int
 databinchk(mode, buffer, bsize, offset, errmsg)
 int mode;	/* either a, c, r, z, o, or C */
-unsigned char *buffer;	/* buffer pointer */
+char *buffer;	/* buffer pointer */
 int bsize;	/* size of buffer */
 int offset;	/* offset into the file where buffer starts */
 char **errmsg;
@@ -102,7 +102,7 @@ char **errmsg;
     long expbits;
     long actbits;
 
-	chr=buffer;
+	chr = (unsigned char *) buffer;
 	total=bsize;
 
 	if (errmsg != NULL) {
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw

Re: [LTP] [PATCH 1/6] ltp: fix databinchk() definition

Hi!

include/databin.h line 42

Quoted 2 lines
include/databin.h +1 -1
-void databinchedk( int mode, unsigned char *buffer, int bsize, int offset, char **errmsg);
+int databinchk( int mode, char *buffer, int bsize, int offset, char **errmsg);

You've forgotten to remove the space here "databinchk( int".

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): 1302102133.2505.26.camel@doink

#4 lore raw

Re: [LTP] [PATCH 1/6] ltp: fix databinchk() definition

Hi!

Quoted 9 lines
Quoted 4 lines

include/databin.h line 42

Quoted 2 lines
include/databin.h +1 -1
-void databinchedk( int mode, unsigned char *buffer, int bsize, int offset, char **errmsg);
+int databinchk( int mode, char *buffer, int bsize, int offset, char **errmsg);

You've forgotten to remove the space here "databinchk( int".

I'll happily fix that (or whoever commits it is welcome to). I was just preserving the exiting formatting. Might as well drop the spaces in the declaration of databingen() next to it as well.

Okay. So I'll commit this as it is. Feel free to send another patch that fixes the whitespace madness.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#5 lore raw

PATCH 2/6 ltp: move type definitions up in "doio.c"

In reply to Alex Elder

The definitions of some types are spread around in the file "testcases/kernel/fs/doio/doio.c". Group them near the top of the file. This is in preparation for the next change, which adds full-fledged C prototypes for all functions in the file.

All changes in this patch are simple "bulk moves" of blocks of code from one place in the file to another.

---
 testcases/kernel/fs/doio/doio.c |  220 +++++++++++++++++++-------------------
 1 files changed, 110 insertions(+), 110 deletions(-)
testcases/kernel/fs/doio/doio.c +110 -110
index a2c50aa..65b76da 100644
@@ -87,6 +87,115 @@
 #include "random_range.h"
 #include "string_to_tokens.h"
 
+#define	NMEMALLOC	32
+#define	MEM_DATA	1	/* data space 				*/
+#define	MEM_SHMEM	2	/* System V shared memory 		*/
+#define	MEM_T3ESHMEM	3	/* T3E Shared Memory 			*/
+#define	MEM_MMAP	4	/* mmap(2) 				*/
+
+#define	MEMF_PRIVATE	0001
+#define	MEMF_AUTORESRV	0002
+#define	MEMF_LOCAL	0004
+#define	MEMF_SHARED	0010
+
+#define	MEMF_FIXADDR	0100
+#define	MEMF_ADDR	0200
+#define	MEMF_AUTOGROW	0400
+#define	MEMF_FILE	01000	/* regular file -- unlink on close	*/
+#define	MEMF_MPIN	010000	/* use mpin(2) to lock pages in memory */
+
+struct memalloc {
+	int	memtype;
+	int	flags;
+	int	nblks;
+	char	*name;
+	void	*space;		/* memory address of allocated space */
+	int	fd;		/* FD open for mmaping */
+	int	size;
+}	Memalloc[NMEMALLOC];
+
+/*
+ * Structure for maintaining open file test descriptors.  Used by
+ * alloc_fd().
+ */
+
+struct fd_cache {
+	char    c_file[MAX_FNAME_LENGTH+1];
+	int	c_oflags;
+	int	c_fd;
+	long    c_rtc;
+#ifdef sgi
+	int	c_memalign;	/* from F_DIOINFO */
+	int	c_miniosz;
+	int	c_maxiosz;
+#endif
+#ifndef CRAY
+	void	*c_memaddr;	/* mmapped address */
+	int	c_memlen;	/* length of above region */
+#endif
+};
+
+/*
+ * Name-To-Value map
+ * Used to map cmdline arguments to values
+ */
+struct smap {
+	char    *string;
+	int	value;
+};
+
+struct aio_info {
+	int			busy;
+	int			id;
+	int			fd;
+	int			strategy;
+	volatile int		done;
+#ifdef CRAY
+	struct iosw		iosw;
+#endif
+#ifdef sgi
+	aiocb_t			aiocb;
+	int			aio_ret;	/* from aio_return */
+	int			aio_errno;	/* from aio_error */
+#endif
+	int			sig;
+	int			signalled;
+	struct sigaction	osa;
+};
+
+/* ---------------------------------------------------------------------------
+ *
+ * A new paradigm of doing the r/w system call where there is a "stub"
+ * function that builds the info for the system call, then does the system
+ * call; this is called by code that is common to all system calls and does
+ * the syscall return checking, async I/O wait, iosw check, etc.
+ *
+ * Flags:
+ *	WRITE, ASYNC, SSD/SDS,
+ *	FILE_LOCK, WRITE_LOG, VERIFY_DATA,
+ */
+
+struct	status {
+	int	rval;		/* syscall return */
+	int	err;		/* errno */
+	int	*aioid;		/* list of async I/O structures */
+};
+
+struct syscall_info {
+	char		*sy_name;
+	int		sy_type;
+	struct status	*(*sy_syscall)();
+	int		(*sy_buffer)();
+	char		*(*sy_format)();
+	int		sy_flags;
+	int		sy_bits;
+};
+
+#define	SY_WRITE		00001
+#define	SY_ASYNC		00010
+#define	SY_IOSW			00020
+#define	SY_SDS			00100
+
 #ifndef O_SSD
 #define O_SSD 0	    	/* so code compiles on a CRAY2 */
 #endif
@@ -173,33 +282,6 @@ int	havesigint = 0;
 
 #define SKIP_REQ	-2	/* skip I/O request */
 
-#define	NMEMALLOC	32
-#define	MEM_DATA	1	/* data space 				*/
-#define	MEM_SHMEM	2	/* System V shared memory 		*/
-#define	MEM_T3ESHMEM	3	/* T3E Shared Memory 			*/
-#define	MEM_MMAP	4	/* mmap(2) 				*/
-
-#define	MEMF_PRIVATE	0001
-#define	MEMF_AUTORESRV	0002
-#define	MEMF_LOCAL	0004
-#define	MEMF_SHARED	0010
-
-#define	MEMF_FIXADDR	0100
-#define	MEMF_ADDR	0200
-#define	MEMF_AUTOGROW	0400
-#define	MEMF_FILE	01000	/* regular file -- unlink on close	*/
-#define MEMF_MPIN	010000	/* use mpin(2) to lock pages in memory */
-
-struct memalloc {
-	int	memtype;
-	int	flags;
-	int	nblks;
-	char	*name;
-	void	*space;		/* memory address of allocated space */
-	int	fd;		/* FD open for mmaping */
-	int	size;
-}	Memalloc[NMEMALLOC];
-
 /*
  * Global file descriptors
  */
@@ -207,27 +289,6 @@ struct memalloc {
 int 	Wfd_Append; 	    /* for appending to the write-log	    */
 int 	Wfd_Random; 	    /* for overlaying write-log entries	    */
 
-/*
- * Structure for maintaining open file test descriptors.  Used by
- * alloc_fd().
- */
-
-struct fd_cache {
-	char    c_file[MAX_FNAME_LENGTH+1];
-	int	c_oflags;
-	int	c_fd;
-	long    c_rtc;
-#ifdef sgi
-	int	c_memalign;	/* from F_DIOINFO */
-	int	c_miniosz;
-	int	c_maxiosz;
-#endif
-#ifndef CRAY
-	void	*c_memaddr;	/* mmapped address */
-	int	c_memlen;	/* length of above region */
-#endif
-};
-
 #define FD_ALLOC_INCR	32      /* allocate this many fd_map structs	*/
 				/* at a time */
 
@@ -297,15 +358,6 @@ struct	fd_cache *alloc_fdcache(char *, int);
 
 #define U_ALL	    	(U_CORRUPTION | U_IOSW | U_RVAL)
 
-/*
- * Name-To-Value map
- * Used to map cmdline arguments to values
- */
-struct smap {
-	char    *string;
-	int	value;
-};
-
 struct smap Upanic_Args[] = {
 	{ "corruption",	U_CORRUPTION	},
 	{ "iosw",	U_IOSW		},
@@ -314,25 +366,6 @@ struct smap Upanic_Args[] = {
 	{ NULL,         0               }
 };
 
-struct aio_info {
-	int			busy;
-	int			id;
-	int			fd;
-	int			strategy;
-	volatile int		done;
-#ifdef CRAY
-	struct iosw		iosw;
-#endif
-#ifdef sgi
-	aiocb_t			aiocb;
-	int			aio_ret;	/* from aio_return */
-	int			aio_errno;	/* from aio_error */
-#endif
-	int			sig;
-	int			signalled;
-	struct sigaction	osa;
-};
-
 struct aio_info	Aio_Info[MAX_AIO];
 
 struct aio_info	*aio_slot();
@@ -2220,39 +2253,6 @@ struct io_req	*req;
 
 #endif /* _CRAY1 */
 
-/* ---------------------------------------------------------------------------
- *
- * A new paradigm of doing the r/w system call where there is a "stub"
- * function that builds the info for the system call, then does the system
- * call; this is called by code that is common to all system calls and does
- * the syscall return checking, async I/O wait, iosw check, etc.
- *
- * Flags:
- *	WRITE, ASYNC, SSD/SDS,
- *	FILE_LOCK, WRITE_LOG, VERIFY_DATA,
- */
-
-struct	status {
-	int	rval;		/* syscall return */
-	int	err;		/* errno */
-	int	*aioid;		/* list of async I/O structures */
-};
-
-struct syscall_info {
-	char		*sy_name;
-	int		sy_type;
-	struct status	*(*sy_syscall)();
-	int		(*sy_buffer)();
-	char		*(*sy_format)();
-	int		sy_flags;
-	int		sy_bits;
-};
-
-#define	SY_WRITE		00001
-#define	SY_ASYNC		00010
-#define	SY_IOSW			00020
-#define	SY_SDS			00100
-
 char *
 fmt_ioreq(struct io_req *ioreq, struct syscall_info *sy, int fd)
 {
@@ -5435,4 +5435,4 @@ FILE	*stream;
 	fprintf(stream, "\t                     of io_req structures (see doio.h).  Currently\n");
 	fprintf(stream, "\t                     only the iogen program generates the proper\n");
 	fprintf(stream, "\t                     format\n");
-}
\ No newline at end of file
+}
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#6 lore raw

Re: [LTP] [PATCH 2/6] ltp: move type definitions up in "doio.c"

Hi!

testcases/kernel/fs/doio/doio.c line 192

Quoted 9 lines
testcases/kernel/fs/doio/doio.c +9 -0
+struct syscall_info {
+	char		*sy_name;
+	int		sy_type;
+	struct status	*(*sy_syscall)();
+	int		(*sy_buffer)();
+	char		*(*sy_format)();
+	int		sy_flags;
+	int		sy_bits;
+};

Ideally these callbacks should have defined their parameters too. Otherwise the compiler can't check if we passed somehow correct parametetrs. Somethink like (*fn)(int, void*, char); should be enough.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#7 lore raw

PATCH 3/6 ltp: use C function prototypes in "doio.c"

In reply to Alex Elder

Many functions in "doio.c" are defined using old-style C declarations. Convert all functions so they follow standard C, and include standard prototypes for each.

Every function (except main()) now has a standard C prototype, and all prototypes are grouped in the same section of the file. The prototypes--as well as the function definitions themselves--now follow a consistent formatting style.

One more change was made, to some signal handler functions. Previously, a few of them were defined without an integer argument, and so did not comply with the definition of a sighandler_t function (defined in signal(2)). These have been fixed to conform.

---
 testcases/kernel/fs/doio/doio.c |  448 +++++++++++++++++++--------------------
 1 files changed, 216 insertions(+), 232 deletions(-)
testcases/kernel/fs/doio/doio.c +216 -232
index 65b76da..b22b590 100644
@@ -86,6 +86,7 @@
 #include "write_log.h"
 #include "random_range.h"
 #include "string_to_tokens.h"
+#include "pattern.h"
 
 #define	NMEMALLOC	32
 #define	MEM_DATA	1	/* data space 				*/
@@ -311,42 +312,158 @@ int	Pattern_Length;
  * Signal handlers, and related globals
  */
 
-void	sigint_handler();	/* Catch SIGINT in parent doio, propagate
-				 * to children, does not die. */
+char		*syserrno(int err);
+void		doio(void);
+void		doio_delay(void);
+char		*format_oflags(int oflags);
+char		*format_strat(int strategy);
+char		*format_rw(struct io_req *ioreq, int fd, void *buffer,
+			int signo, char *pattern, void *iosw);
+#ifdef CRAY
+char		*format_sds(struct io_req *ioreq, void *buffer, int sds
+			char *pattern);
+#endif /* CRAY */
+
+int		do_read(struct io_req *req);
+int		do_write(struct io_req *req);
+int		lock_file_region(char *fname, int fd, int type, int start,
+			int nbytes);
 
-void	die_handler();		/* Bad sig in child doios, exit 1. */
-void	cleanup_handler();	/* Normal kill, exit 0. */
+#ifdef CRAY
+char		*format_listio(struct io_req *ioreq, int lcmd,
+			struct listreq *list, int nent, int fd, char *pattern);
+#endif /* CRAY */
+
+int		do_listio(struct io_req *req);
+
+#if defined(_CRAY1) || defined(CRAY)
+int		do_ssdio(struct io_req *req);
+#endif /* defined(_CRAY1) || defined(CRAY) */
+
+char		*fmt_ioreq(struct io_req *ioreq, struct syscall_info *sy,
+			int fd);
+
+#ifdef CRAY
+struct status	*sy_listio(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+int		listio_mem(struct io_req *req, int offset, int fmstride,
+			int *min, int *max);
+char		*fmt_listio(struct io_req *req, struct syscall_info *sy,
+			int fd, char *addr);
+#endif /* CRAY */
+
+#ifdef sgi
+struct status	*sy_pread(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_pwrite(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+char		*fmt_pread(struct io_req *req, struct syscall_info *sy,
+			int fd, char *addr);
+#endif	/* sgi */
 
 #ifndef CRAY
-void	sigbus_handler();	/* Handle sigbus--check active_mmap_rw to
-				   decide if this should be a normal exit. */
-#endif
+struct status	*sy_readv(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_writev(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_rwv(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr, int rw);
+char		*fmt_readv(struct io_req *req, struct syscall_info *sy,
+			int fd, char *addr);
+#endif /* !CRAY */
 
-void	cb_handler();		/* Posix aio callback handler. */
-void	noop_handler();		/* Delayop alarm, does nothing. */
-char	*hms();
-char	*format_rw();
-char	*format_sds();
-char	*format_listio();
-char	*check_file();
-int	doio_fprintf(FILE *stream, char *format, ...);
-void	doio_upanic();
-void	doio();
-void	help();
-void	doio_delay();
-int     alloc_fd( char *, int );
-int     alloc_mem( int );
-int     do_read( struct io_req * );
-int     do_write( struct io_req * );
-int     do_rw( struct io_req * );
-int     do_sync( struct io_req * );
-int     usage( FILE * );
-int     aio_unregister( int );
-int	pattern_check(char *buf, int buflen, char *pat, int patlen, int patshift);
-int	pattern_fill(char *buf, int buflen, char *pat, int patlen, int patshift);
-int     parse_cmdline( int, char **, char * );
-int     lock_file_region( char *, int, int, int, int );
-struct	fd_cache *alloc_fdcache(char *, int);
+#ifdef sgi
+struct status	*sy_aread(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_awrite(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr)
+struct status	*sy_arw(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr, int rw);
+char		*fmt_aread(struct io_req *req, struct syscall_info *sy,
+			int fd, char *addr);
+#endif /* sgi */
+
+#ifndef CRAY
+struct status	*sy_mmread(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_mmwrite(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr);
+struct status	*sy_mmrw(struct io_req *req, struct syscall_info *sysc,
+			int fd, char *addr, int rw);
+char		*fmt_mmrw(struct io_req *req, struct syscall_info *sy, int fd,
+			char *addr);
+#endif /* !CRAY */
+
+int		do_rw(struct io_req *req);
+
+#ifdef sgi
+int		do_fcntl(struct io_req *req);
+#endif /* sgi */
+
+#ifndef CRAY
+int		do_sync(struct io_req *req);
+#endif /* !CRAY */
+
+int		doio_pat_fill(char *addr, int mem_needed, char *Pattern,
+			int Pattern_Length, int shift);
+char		*doio_pat_check(char *buf, int offset, int length,
+			char *pattern, int pattern_length, int patshift);
+char		*check_file(char *file, int offset, int length, char *pattern,
+			int pattern_length, int patshift, int fsa);
+int		doio_fprintf(FILE *stream, char *format, ...);
+int		alloc_mem(int nbytes);
+
+#if defined(_CRAY1) || defined(CRAY)
+int		alloc_sds(int nbytes);
+#endif /* defined(_CRAY1) || defined(CRAY) */
+
+int		alloc_fd(char *file, int oflags);
+struct fd_cache	*alloc_fdcache(char *file, int oflags);
+
+#ifdef sgi
+void		signal_info(int sig, siginfo_t *info, void *v);
+void		cleanup_handler(int sig, siginfo_t *info, void *v);
+void		die_handler(int sig, siginfo_t *info, void *v);
+void		sigbus_handler(int sig, siginfo_t *info, void *v);
+#else	/* !sgi */
+void		cleanup_handler(int sig);
+void		die_handler(int sig);
+
+#ifndef CRAY
+void		sigbus_handler(int sig);
+#endif /* !CRAY */
+#endif /* sgi */
+
+void		noop_handler(int sig);
+void		sigint_handler(int sig);
+void		aio_handler(int sig);
+void		dump_aio(void);
+
+#ifdef sgi
+void		cb_handler(sigval_t val);
+#endif /* sgi */
+
+struct aio_info	*aio_slot(int aio_id);
+int		aio_register(int fd, int strategy, int sig);
+int		aio_unregister(int aio_id);
+
+#ifndef __linux__
+int		aio_wait(int aio_id);
+#endif /* !__linux__ */
+
+char		*hms(time_t t);
+int		aio_done(struct aio_info *ainfo);
+void		doio_upanic(int mask);
+int		parse_cmdline(int argc, char **argv, char *opts);
+
+#ifndef CRAY
+void		parse_memalloc(char *arg);
+void		dump_memalloc(void);
+#endif /* !CRAY */
+
+void		parse_delay(char *arg);
+int		usage(FILE *stream);
+void		help(FILE *stream);
 
 /*
  * Upanic conditions, and a map from symbolics to values
@@ -368,9 +485,6 @@ struct smap Upanic_Args[] = {
 
 struct aio_info	Aio_Info[MAX_AIO];
 
-struct aio_info	*aio_slot();
-int     aio_done( struct aio_info * );
-
 /* -C data-fill/check type */
 #define	C_DEFAULT	1
 struct smap checkmap[] = {
@@ -410,9 +524,7 @@ syserrno(int err)
 ******/
 
 int
-main(argc, argv)
-int 	argc;
-char	**argv;
+main(int argc, char **argv)
 {
 	int	    	    	i, pid, stat, ex_stat;
 #ifdef CRAY
@@ -644,7 +756,7 @@ char	**argv;
  */
 
 void
-doio()
+doio(void)
 {
 	int	    	    	rval, i, infd, nbytes;
 	char			*cp;
@@ -973,7 +1085,7 @@ doio()
 }  /* doio */
 
 void
-doio_delay()
+doio_delay(void)
 {
 	struct timeval tv_delay;
 	struct sigaction sa_al, sa_old;
@@ -1151,18 +1263,8 @@ format_strat(int strategy)
 }
 
 char *
-format_rw(
-	struct	io_req	*ioreq,
-	int		fd,
-	void		*buffer,
-	int		signo,
-	char		*pattern,
-#ifdef CRAY
-	struct	iosw	*iosw
-#else
-	void		*iosw
-#endif
-	)
+format_rw(struct io_req *ioreq, int fd, void *buffer, int signo, char *pattern,
+	void *iosw)
 {
 	static char		*errbuf=NULL;
 	char			*aio_strat, *cp;
@@ -1231,12 +1333,7 @@ format_rw(
 
 #ifdef CRAY
 char *
-format_sds(
-	struct	io_req	*ioreq,
-	void		*buffer,
-	int		sds,
-	char		*pattern
-	)
+format_sds(struct io_req *ioreq, void *buffer, int sds, char *pattern)
 {
 	int			i;
 	static char		*errbuf=NULL;
@@ -1271,8 +1368,7 @@ format_sds(
  */
 
 int
-do_read(req)
-struct io_req	*req;
+do_read(struct io_req *req)
 {
 	int	    	    	fd, offset, nbytes, oflags, rval;
 	char    	    	*addr, *file;
@@ -1462,8 +1558,7 @@ struct io_req	*req;
  */
 
 int
-do_write(req)
-struct io_req	*req;
+do_write(struct io_req *req)
 {
 	static int		pid = -1;
 	int	    	    	fd, nbytes, oflags, signo;
@@ -1817,12 +1912,7 @@ struct io_req	*req;
  */
 
 int
-lock_file_region(fname, fd, type, start, nbytes)
-char	*fname;
-int	fd;
-int	type;
-int	start;
-int	nbytes;
+lock_file_region(char *fname, int fd, int type, int start, int nbytes)
 {
 	struct flock	flk;
 
@@ -1849,14 +1939,8 @@ int	nbytes;
 
 #ifdef CRAY
 char *
-format_listio(
-	struct	io_req	*ioreq,
-	int		lcmd,
-	struct listreq	*list,
-	int		nent,
-	int		fd,
-	char		*pattern
-	)
+format_listio(struct io_req *ioreq, int lcmd, struct listreq *list,
+	int nent, int fd, char *pattern)
 {
 	static	char		*errbuf=NULL;
 	struct	listio_req	*liop = &ioreq->r_data.listio;
@@ -1912,8 +1996,7 @@ format_listio(
 #endif /* CRAY */
 
 int
-do_listio(req)
-struct io_req	*req;
+do_listio(struct io_req *req)
 {
 #ifdef CRAY
 	struct listio_req	*lio;
@@ -2167,8 +2250,7 @@ struct io_req	*req;
 #ifdef _CRAY1
 
 int
-do_ssdio(req)
-struct io_req	*req;
+do_ssdio(struct io_req *req)
 {
 	int	    nbytes, nb;
 	char    errbuf[BSIZE];
@@ -2240,8 +2322,7 @@ struct io_req	*req;
 #ifdef CRAY
 
 int
-do_ssdio(req)
-struct io_req	*req;
+do_ssdio(struct io_req *req)
 {
 	doio_fprintf(stderr,
 		     "Internal Error - do_ssdio() called on a non-cray1 system\n");
@@ -2249,7 +2330,7 @@ struct io_req	*req;
 	exit(E_INTERNAL);
 }
 
-#endif
+#endif /* CRAY */
 
 #endif /* _CRAY1 */
 
@@ -2350,11 +2431,7 @@ fmt_ioreq(struct io_req *ioreq, struct syscall_info *sy, int fd)
  */
 #ifdef CRAY
 struct status *
-sy_listio(req, sysc, fd, addr)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_listio(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	int		offset, nbytes, nstrides, nents, aio_strat;
 	int		aio_id, signo, o, i, lc;
@@ -2435,8 +2512,7 @@ char *addr;
  * This assumes filestride & memstride = 0.
  */
 int
-listio_mem(struct io_req *req, int offset, int fmstride,
-	   int *min, int *max)
+listio_mem(struct io_req *req, int offset, int fmstride, int *min, int *max)
 {
 	int	i, size;
 
@@ -2477,11 +2553,7 @@ fmt_listio(struct io_req *req, struct syscall_info *sy, int fd, char *addr)
 
 #ifdef sgi
 struct status *
-sy_pread(req, sysc, fd, addr)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_pread(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	int rc;
 	struct status	*status;
@@ -2503,11 +2575,7 @@ char *addr;
 }
 
 struct status *
-sy_pwrite(req, sysc, fd, addr)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_pwrite(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	int rc;
 	struct status	*status;
@@ -2552,34 +2620,22 @@ fmt_pread(struct io_req *req, struct syscall_info *sy, int fd, char *addr)
 
 #ifndef CRAY
 struct status *
-sy_readv(req, sysc, fd, addr)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_readv(struct io_req	*req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_rwv();
 	return sy_rwv(req, sysc, fd, addr, 0);
 }
 
 struct status *
-sy_writev(req, sysc, fd, addr)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_writev(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_rwv();
 	return sy_rwv(req, sysc, fd, addr, 1);
 }
 
 struct status *
-sy_rwv(req, sysc, fd, addr, rw)
-struct io_req	*req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
-int rw;
+sy_rwv(struct io_req *req, struct syscall_info *sysc, int fd, char *addr,
+	int rw)
 {
 	int rc;
 	struct status	*status;
@@ -2628,22 +2684,14 @@ fmt_readv(struct io_req *req, struct syscall_info *sy, int fd, char *addr)
 
 #ifdef sgi
 struct status *
-sy_aread(req, sysc, fd, addr)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_aread(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_arw();
 	return sy_arw(req, sysc, fd, addr, 0);
 }
 
 struct status *
-sy_awrite(req, sysc, fd, addr)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_awrite(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_arw();
 	return sy_arw(req, sysc, fd, addr, 1);
@@ -2655,12 +2703,8 @@ char *addr;
  */
 
 struct status *
-sy_arw(req, sysc, fd, addr, rw)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
-int rw;
+sy_arw(struct io_req *req, struct syscall_info *sysc, int fd, char *addr,
+	int rw)
 {
 	/* POSIX 1003.1b-1993 Async read */
 	struct status		*status;
@@ -2736,34 +2780,22 @@ fmt_aread(struct io_req *req, struct syscall_info *sy, int fd, char *addr)
 #ifndef CRAY
 
 struct status *
-sy_mmread(req, sysc, fd, addr)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_mmread(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_mmrw();
 	return sy_mmrw(req, sysc, fd, addr, 0);
 }
 
 struct status *
-sy_mmwrite(req, sysc, fd, addr)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
+sy_mmwrite(struct io_req *req, struct syscall_info *sysc, int fd, char *addr)
 {
 	struct status *sy_mmrw();
 	return sy_mmrw(req, sysc, fd, addr, 1);
 }
 
 struct status *
-sy_mmrw(req, sysc, fd, addr, rw)
-struct io_req *req;
-struct syscall_info *sysc;
-int fd;
-char *addr;
-int rw;
+sy_mmrw(struct io_req *req, struct syscall_info *sysc, int fd, char *addr,
+	int rw)
 {
 	/*
 	 * mmap read/write
@@ -2958,8 +2990,7 @@ struct syscall_info syscalls[] = {
 };
 
 int
-do_rw(req)
-	struct io_req	*req;
+do_rw(struct io_req *req)
 {
 	static int		pid = -1;
 	int	    		fd, offset, nbytes, nstrides, nents, oflags;
@@ -3382,8 +3413,7 @@ do_rw(req)
  */
 #ifdef sgi
 int
-do_fcntl(req)
-	struct io_req	*req;
+do_fcntl(struct io_req *req)
 {
 	int	    		fd, oflags, offset, nbytes;
 	int			rval, op;
@@ -3474,15 +3504,14 @@ do_fcntl(req)
 
 	return (rval == -1) ? -1 : 0;
 }
-#endif
+#endif /* sgi */
 
 /*
  *  fsync(2) and fdatasync(2)
  */
 #ifndef CRAY
 int
-do_sync(req)
-	struct io_req	*req;
+do_sync(struct io_req *req)
 {
 	int	    		fd, oflags;
 	int			rval;
@@ -3516,23 +3545,18 @@ do_sync(req)
 	}
 	return (rval == -1) ? -1 : 0;
 }
-#endif
+#endif /* !CRAY */
 
 int
 doio_pat_fill(char *addr, int mem_needed, char *Pattern, int Pattern_Length,
-	      int shift)
+	int shift)
 {
 	return pattern_fill(addr, mem_needed, Pattern, Pattern_Length, 0);
 }
 
 char *
-doio_pat_check(buf, offset, length, pattern, pattern_length, patshift)
-char	*buf;
-int	offset;
-int 	length;
-char	*pattern;
-int	pattern_length;
-int	patshift;
+doio_pat_check(char *buf, int offset, int length, char *pattern,
+	int pattern_length, int patshift)
 {
 	static char	errbuf[4096];
 	int		nb, i, pattern_index;
@@ -3610,14 +3634,8 @@ int	patshift;
  */
 
 char *
-check_file(file, offset, length, pattern, pattern_length, patshift, fsa)
-char 	*file;
-int 	offset;
-int 	length;
-char	*pattern;
-int	pattern_length;
-int	patshift;
-int	fsa;
+check_file(char *file, int offset, int length, char *pattern,
+	int pattern_length, int patshift, int fsa)
 {
 	static char	errbuf[4096];
 	int	    	fd, nb, flags;
@@ -3742,8 +3760,7 @@ doio_fprintf(FILE *stream, char *format, ...)
  */
 #ifndef CRAY
 int
-alloc_mem(nbytes)
-int nbytes;
+alloc_mem(int nbytes)
 {
 	char    	*cp;
 	void		*addr;
@@ -4002,12 +4019,9 @@ int nbytes;
 	mturn++;
 	return 0;
 }
-#endif /* !CRAY */
-
-#ifdef CRAY
+#else /* CRAY */
 int
-alloc_mem(nbytes)
-int nbytes;
+alloc_mem(int nbytes)
 {
 	char    *cp;
 	int	ip;
@@ -4083,8 +4097,7 @@ int nbytes;
 #ifdef _CRAY1
 
 int
-alloc_sds(nbytes)
-int nbytes;
+alloc_sds(int nbytes)
 {
 	int nblks;
 
@@ -4107,8 +4120,7 @@ int nbytes;
 #ifdef CRAY
 
 int
-alloc_sds(nbytes)
-int	nbytes;
+alloc_sds(int nbytes)
 {
 	doio_fprintf(stderr,
 		     "Internal Error - alloc_sds() called on a CRAY2 system\n");
@@ -4133,9 +4145,7 @@ int	nbytes;
  */
 
 int
-alloc_fd(file, oflags)
-char	*file;
-int	oflags;
+alloc_fd(char *file, int oflags)
 {
 	struct fd_cache *fdc;
 	struct fd_cache *alloc_fdcache(char *file, int oflags);
@@ -4148,9 +4158,7 @@ int	oflags;
 }
 
 struct fd_cache *
-alloc_fdcache(file, oflags)
-char	*file;
-int	oflags;
+alloc_fdcache(char *file, int oflags)
 {
 	int			fd;
 	struct fd_cache		*free_slot, *oldest_slot, *cp;
@@ -4369,9 +4377,7 @@ signal_info(int sig, siginfo_t *info, void *v)
 		doio_fprintf(stderr, "signal_info: sig %d\n", sig);
 	}
 }
-#endif
 
-#ifdef sgi
 void
 cleanup_handler(int sig, siginfo_t *info, void *v)
 {
@@ -4419,7 +4425,7 @@ sigbus_handler(int sig, siginfo_t *info, void *v)
 #else
 
 void
-cleanup_handler()
+cleanup_handler(int sig)
 {
 	havesigint=1; /* in case there's a followup signal */
 	alloc_mem(-1);
@@ -4427,8 +4433,7 @@ cleanup_handler()
 }
 
 void
-die_handler(sig)
-int sig;
+die_handler(int sig)
 {
 	doio_fprintf(stderr, "terminating on signal %d\n", sig);
 	alloc_mem(-1);
@@ -4437,8 +4442,7 @@ int sig;
 
 #ifndef CRAY
 void
-sigbus_handler(sig)
-int sig;
+sigbus_handler(int sig)
 {
 	/* See sigbus_handler() in the 'ifdef sgi' case for details.  Here,
 	   we don't have the siginfo stuff so the guess is weaker but we'll
@@ -4446,7 +4450,7 @@ int sig;
 	*/
 
 	if (active_mmap_rw && havesigint)
-		cleanup_handler();
+		cleanup_handler(sig);
 	else
 		die_handler(sig);
 }
@@ -4454,8 +4458,7 @@ int sig;
 #endif /* sgi */
 
 void
-noop_handler(sig)
-int sig;
+noop_handler(int sig)
 {
 	return;
 }
@@ -4467,7 +4470,7 @@ int sig;
  */
 
 void
-sigint_handler()
+sigint_handler(int sig)
 {
 	int	i;
 
@@ -4485,8 +4488,7 @@ sigint_handler()
  */
 
 void
-aio_handler(sig)
-int	sig;
+aio_handler(int sig)
 {
 	unsigned int	i;
 	struct aio_info	*aiop;
@@ -4508,7 +4510,7 @@ int	sig;
  * dump info on all open aio slots
  */
 void
-dump_aio()
+dump_aio(void)
 {
 	unsigned int	i, count;
 
@@ -4536,8 +4538,7 @@ dump_aio()
  * Aio_Info[] index.
  */
 void
-cb_handler(val)
-sigval_t val;
+cb_handler(sigval_t val)
 {
 	struct aio_info	*aiop;
 
@@ -4557,8 +4558,7 @@ sigval_t val;
 #endif
 
 struct aio_info *
-aio_slot(aio_id)
-int	aio_id;
+aio_slot(int aio_id)
 {
 	unsigned int	i;
 	static int	id = 1;
@@ -4594,13 +4594,9 @@ int	aio_id;
 }
 
 int
-aio_register(fd, strategy, sig)
-int		fd;
-int		strategy;
-int		sig;
+aio_register(int fd, int strategy, int sig)
 {
 	struct aio_info		*aiop;
-	void			aio_handler();
 	struct sigaction	sa;
 
 	aiop = aio_slot(-1);
@@ -4630,8 +4626,7 @@ int		sig;
 }
 
 int
-aio_unregister(aio_id)
-int	aio_id;
+aio_unregister(int aio_id)
 {
 	struct aio_info	*aiop;
 
@@ -4647,8 +4642,7 @@ int	aio_id;
 
 #ifndef __linux__
 int
-aio_wait(aio_id)
-int	aio_id;
+aio_wait(int aio_id)
 {
 #ifdef RECALL_SIZEOF
 	long		mask[RECALL_SIZEOF];
@@ -4771,8 +4765,7 @@ int	aio_id;
  */
 
 char *
-hms(t)
-time_t	t;
+hms(time_t t)
 {
 	static char	ascii_time[9];
 	struct tm	*ltime;
@@ -4826,8 +4819,7 @@ aio_done(struct aio_info *ainfo)
  */
 
 void
-doio_upanic(mask)
-int	mask;
+doio_upanic(int mask)
 {
 	if (U_opt == 0 || (mask & Upanic_Conditions) == 0) {
 		return;
@@ -4854,10 +4846,7 @@ int	mask;
  */
 
 int
-parse_cmdline(argc, argv, opts)
-int 	argc;
-char	**argv;
-char	*opts;
+parse_cmdline(int argc, char **argv, char *opts)
 {
 	int	    	c;
 	char    	cc, *cp=NULL, *tok=NULL;
@@ -4867,9 +4856,6 @@ char	*opts;
 	struct smap	*s;
 	char		*memargs[NMEMALLOC];
 	int		nmemargs, ma;
-	void		parse_memalloc(char *arg);
-	void		parse_delay(char *arg);
-	void		dump_memalloc();
 
 	if (*argv[0] == '-') {
 		argv[0]++;
@@ -5241,7 +5227,7 @@ parse_memalloc(char *arg)
 }
 
 void
-dump_memalloc()
+dump_memalloc(void)
 {
 	int	ma;
 	char	*mt;
@@ -5314,8 +5300,7 @@ parse_delay(char *arg)
  */
 
 int
-usage(stream)
-FILE	*stream;
+usage(FILE *stream)
 {
 	/*
 	 * Only do this if we are on vpe 0, to avoid seeing it from every
@@ -5331,8 +5316,7 @@ FILE	*stream;
 }
 
 void
-help(stream)
-FILE	*stream;
+help(FILE *stream)
 {
 	/*
 	 * Only the app running on vpe 0 gets to issue help - this prevents
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#8 lore raw

PATCH 4/6 ltp: use C function prototypes in "growfiles.c"

In reply to Alex Elder

Many functions in "growfiles.c" are defined using old-style C declarations. Convert all functions so they follow standard C, and include standard prototypes for each.

Every function (except main()) now has a standard C prototype, and all prototypes are grouped in the same section of the file. The prototypes--as well as the function definitions themselves--now follow a consistent formatting style.

---
 testcases/kernel/fs/doio/growfiles.c |  121 ++++++++++++++-------------------
 1 files changed, 51 insertions(+), 70 deletions(-)
testcases/kernel/fs/doio/growfiles.c +51 -70
index f85d47e..2bb21bd 100644
@@ -85,6 +85,9 @@
 #include "dataascii.h"
 #include "random_range.h"
 #include "databin.h"
+#include "open_flags.h"
+#include "forker.h"
+#include "file_lock.h"
 
 #ifdef CRAY
 #include <sys/panic.h>
@@ -93,6 +96,31 @@
 
 #include "test.h"
 
+int		set_sig(void);
+void		sig_handler(int sig);
+static void	notify_others(void);
+int		handle_error(void);
+int		cleanup(void);
+void		usage(void);
+void		help(void);
+void		prt_examples(FILE *stream);
+int		growfile(int fd, char *file, int grow_incr, char *buf,
+			unsigned long *curr_size_ptr);
+int		shrinkfile(int fd, char *filename, int trunc_incr,
+			int trunc_inter, int just_trunc);
+int		check_write(int fd, int cf_inter, char *filename, int mode);
+int		check_file(int fd, int cf_inter, char *filename,
+			int no_file_check);
+int		file_size(int fd);
+int		lkfile(int fd, int operation, int lklevel);
+
+#ifndef linux
+int		pre_alloc(int fd, long size);
+#endif /* !linux */
+
+extern int	datapidgen(int, char *, int, int);
+extern int	datapidchk(int, char *, int, int, char **);
+
 /* LTP status reporting */
 char *TCID="growfiles";		/* Default test program identifier.    */
 int TST_TOTAL=1;    		/* Total number of test cases. */
@@ -109,35 +137,6 @@ myexit (int x)
   tst_exit();
 }
 
-extern char *openflags2symbols();
-
-extern int parse_open_flags();
-extern int background();
-extern int forker();
-extern int datapidgen();
-extern void databingen();
-extern int datapidchk();
-extern int databinchk();
-extern int file_lock();
-
-int file_size();
-int check_write();
-int shrinkfile();
-int check_file();
-int growfile();
-int cleanup();
-int handle_error();
-int lkfile();
-void usage();
-void help();
-void prt_examples();
-int set_sig();
-void sig_handler();
-static void notify_others();
-#ifndef linux
-int pre_alloc();
-#endif
-
 #define NEWIO	1	/* Use the tlibio.c functions */
 
 #ifndef NEWIO
@@ -345,9 +344,7 @@ int Open_flags[] = {
  * MAIN
  ***********************************************************************/
 int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
 {
 extern char *optarg;            /* used by getopt */
 extern int optind;
@@ -372,8 +369,8 @@ int num;
 int fd;				/* file descriptor */
 int stop = 0;			/* loop stopper if set */
 
-long unsigned curr_size = 0;			/* BUG:14136 (keep track of file size) */
-const long unsigned ext2_limit = 2147483647;	/* BUG:14136 (2GB ext2 filesize limit) */
+unsigned long curr_size = 0;			/* BUG:14136 (keep track of file size) */
+const unsigned long ext2_limit = 2147483647;	/* BUG:14136 (2GB ext2 filesize limit) */
 
 off_t tmp;
 char chr;
@@ -1359,7 +1356,7 @@ no whole file checking will be performed!\n", Progname, TagName, getpid());
 		if (Debug > 3) {
 		    printf("%s: %d DEBUG3 %s/%d: %d Open filename = %s, open flags = %#o %s\n",
 			Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret,
-		        openflags2symbols(ret, ",", NULL));
+		        openflags2symbols(ret, ",", 0));
 		} else if (Debug > 2) {
 		    printf("%s: %d DEBUG3 %s/%d: %d filename = %s, open flags = %#o\n",
 			Progname, Pid, __FILE__, __LINE__, Iter_cnt, filename, ret);
@@ -1534,9 +1531,9 @@ no whole file checking will be performed!\n", Progname, TagName, getpid());
  *
  ***********************************************************************/
 int
-set_sig()
+set_sig(void)
 {
-   int sig;
+	int sig;
 
         /*
          * now loop through all signals and set the handlers
@@ -1578,8 +1575,7 @@ set_sig()
  *
  ***********************************************************************/
 void
-sig_handler(sig)
-int sig;
+sig_handler(int sig)
 {
     int exit_stat = 2;
 
@@ -1617,7 +1613,7 @@ int sig;
  *
  ***********************************************************************/
 static void
-notify_others()
+notify_others(void)
 {
     static int send_signals = 0;
     int ind;
@@ -1651,7 +1647,7 @@ notify_others()
  * and exit is Maxerrs were encountered.
  ***********************************************************************/
 int
-handle_error()
+handle_error(void)
 {
     Errors++;
 
@@ -1683,9 +1679,9 @@ handle_error()
  *
  ***********************************************************************/
 int
-cleanup()
+cleanup(void)
 {
-    int ind;
+	int ind;
 
 	if (remove_files) {
 	    if (Debug > 2)
@@ -1705,7 +1701,7 @@ cleanup()
  *
  ***********************************************************************/
 void
-usage()
+usage(void)
 {
 	fprintf(stderr,
 	"Usage: %s%s [-bhEluy][[-g grow_incr][-i num][-t trunc_incr][-T trunc_inter]\n",
@@ -1725,7 +1721,7 @@ usage()
  *
  ***********************************************************************/
 void
-help()
+help(void)
 {
 	usage();
 
@@ -1846,13 +1842,9 @@ prt_examples(FILE *stream)
  * Woffset will be set to the offset before the write.
  * Grow_incr will be set to the size of the write or lseek write.
  ***********************************************************************/
-int
-growfile(fd, file, grow_incr, buf, curr_size_ptr)	/* BUG:14136 */
-int fd;
-char *file;
-int grow_incr;
-char *buf;
-long *curr_size_ptr;	/* BUG:14136 */
+int	/* BUG:14136 */
+growfile(int fd, char *file, int grow_incr, char *buf,
+	unsigned long *curr_size_ptr)
 {
    off_t noffset;
    int ret;
@@ -2198,12 +2190,8 @@ long *curr_size_ptr;	/* BUG:14136 */
  *
  ***********************************************************************/
 int
-shrinkfile(fd, filename, trunc_incr, trunc_inter, just_trunc)
-int fd;
-char *filename;
-int trunc_incr;
-int trunc_inter;	/* interval */
-int just_trunc;		/* lseek has already been done for you */
+shrinkfile(int fd, char *filename, int trunc_incr, int trunc_inter,
+	int just_trunc)
 {
     static int shrink_cnt = 0;
     int cur_offset;
@@ -2325,11 +2313,7 @@ int just_trunc;		/* lseek has already been done for you */
  *
  ***********************************************************************/
 int
-check_write(fd, cf_inter, filename, mode)
-int fd;
-int cf_inter;   /* check file interval */
-char *filename; /* needed for error messages */
-int mode;       /* write mode */
+check_write(int fd, int cf_inter, char *filename, int mode)
 {
     int fsize;
     static int cf_count = 0;
@@ -2494,7 +2478,8 @@ int mode;       /* write mode */
 	if (Debug > 0)
 	    printf("%s%s: %d DEBUG1 %s/%d: **fd:%d, lk:%d, offset:%ld, sz:%d open flags:%#o %s\n",
 		Progname, TagName, Pid, __FILE__, __LINE__, fd, lockfile,
-		Woffset, Grow_incr, Fileinfo.openflags, openflags2symbols(Fileinfo.openflags, ",", NULL));
+		Woffset, Grow_incr, Fileinfo.openflags,
+		openflags2symbols(Fileinfo.openflags, ",", 0));
 
 	fflush(stderr);
 	return 1;
@@ -2511,11 +2496,7 @@ int mode;       /* write mode */
  *
  ***********************************************************************/
 int
-check_file(fd, cf_inter, filename, no_file_check)
-int fd;
-int cf_inter;	/* check file interval */
-char *filename;	/* needed for error messages */
-int no_file_check;	/* if set, do not do file content check */
+check_file(int fd, int cf_inter, char *filename, int no_file_check)
 {
     int fsize;
     static int cf_count = 0;
@@ -2842,4 +2823,4 @@ pre_alloc(int fd, long size)
 
 	return 0;
 }
-#endif
\ No newline at end of file
+#endif
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#9 lore raw

PATCH 5/6 ltp: use C function prototypes in "iogen.c"

In reply to Alex Elder

Many functions in "iogen.c" are defined using old-style C declarations. Convert all functions so they follow standard C, and include standard prototypes for each.

Every function (except main()) now has a standard C prototype, and all prototypes are grouped in the same section of the file. The prototypes--as well as the function definitions themselves--now follow a consistent formatting style.

---
 testcases/kernel/fs/doio/iogen.c |   61 +++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 37 deletions(-)
testcases/kernel/fs/doio/iogen.c +24 -37
index 4f46099..167edbd 100644
@@ -113,6 +113,18 @@ struct strmap {
 	int	m_flags;
 };
 
+void		startup_info(FILE *stream, int seed);
+int		init_output(void);
+int		form_iorequest(struct io_req *req);
+int		get_file_info(struct file_info *rec);
+int		create_file(char *path, int nbytes);
+int		str_to_value(struct strmap *map, char *str);
+struct strmap	*str_lookup(struct strmap *map, char *str);
+char		*value_to_string(struct strmap *map, int val);
+int		parse_cmdline(int argc, char **argv, char *opts);
+int		help(FILE *stream);
+int		usage(FILE *stream);
+
 /*
  * Declare cmdline option flags/variables initialized in parse_cmdline()
  */
@@ -165,8 +177,6 @@ int	Fileio = 0;		/* flag indicating that a file		    */
 int	Naio_Strat_Types = 0;	/* # async io completion types		    */
 struct	strmap *Aio_Strat_List[128]; /* Async io completion types	    */
 
-void	startup_info();
-
 /*
  * Map async io completion modes (-a args) names to values.  Macros are
  * defined in doio.h.
@@ -366,16 +376,8 @@ char	Byte_Patterns[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
 			      'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
 			      'Y', 'Z' };
 
-int form_iorequest(struct io_req *);
-int init_output();
-int parse_cmdline(int argc, char **argv, char *opts);
-int help(FILE *stream);
-int usage(FILE *stream);
-
 int
-main(argc, argv)
-int 	argc;
-char	**argv;
+main(int argc, char **argv)
 {
     int	    	    rseed, outfd, infinite;
     time_t  	    start_time;
@@ -533,7 +535,7 @@ startup_info(FILE *stream, int seed)
  * error code if this cannot be done.
  */
 int
-init_output()
+init_output(void)
 {
     int	 outfd;
     struct stat	    sbuf;
@@ -579,8 +581,7 @@ init_output()
  */
 
 int
-form_iorequest(req)
-struct io_req   *req;
+form_iorequest(struct io_req *req)
 {
     int	    	    	mult, offset=0, length=0, slength;
     int	    	    	minlength, maxlength, laststart, lastend;
@@ -926,8 +927,7 @@ struct io_req   *req;
  */
 
 int
-get_file_info(rec)
-struct file_info    *rec;
+get_file_info(struct file_info *rec)
 {
     struct stat			sbuf;
 #ifdef CRAY
@@ -1047,9 +1047,7 @@ struct file_info    *rec;
  */
 
 int
-create_file(path, nbytes)
-char	*path;
-int 	nbytes;
+create_file(char *path, int nbytes)
 {
     int	    	fd, rval;
     char    	c;
@@ -1298,9 +1296,7 @@ int 	nbytes;
  */
 
 int
-str_to_value(map, str)
-struct strmap	*map;
-char	    	*str;
+str_to_value(struct strmap *map, char *str)
 {
     struct strmap   *mp;
 
@@ -1317,9 +1313,7 @@ char	    	*str;
  */
 
 struct strmap *
-str_lookup(map, str)
-struct strmap	*map;
-char	    	*str;
+str_lookup(struct strmap *map, char *str)
 {
     struct strmap   *mp;
 
@@ -1336,9 +1330,7 @@ char	    	*str;
  */
 
 char *
-value_to_string(map, val)
-struct strmap   *map;
-int		val;
+value_to_string(struct strmap *map, int val)
 {
     struct strmap  *mp;
 
@@ -1355,10 +1347,7 @@ int		val;
  */
 
 int
-parse_cmdline(argc, argv, opts)
-int 	argc;
-char	**argv;
-char	*opts;
+parse_cmdline(int argc, char **argv, char *opts)
 {
     int	    	    	o, len, nb, format_error;
     struct strmap	*flgs, *sc;
@@ -1870,8 +1859,7 @@ char	*opts;
 }
 
 int
-help(stream)
-FILE	*stream;
+help(FILE *stream)
 {
     usage(stream);
     fprintf(stream, "\n");
@@ -1981,9 +1969,8 @@ FILE	*stream;
  */
 
 int
-usage(stream)
-FILE	*stream;
+usage(FILE *stream)
 {
     fprintf(stream, "usage%s:  iogen [-hoq] [-a aio_type,...] [-f flag[,flag...]] [-i iterations] [-p outpipe] [-m offset-mode] [-s syscall[,syscall...]] [-t mintrans] [-T maxtrans] [ -O file-create-flags ] [[len:]file ...]\n", TagName);
   return 0;
-}
\ No newline at end of file
+}
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#10 lore raw

PATCH 6/6 ltp: enable -Wall for doio compiles

In reply to Alex Elder

Now that the code has been made modern and a few minor problems have been addressed, enable the "-Wall" flag for gcc when building files under "testcases/kernel/fs/doio/".

---
 testcases/kernel/fs/doio/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
testcases/kernel/fs/doio/Makefile +1 -1
index 2cfc8b7..7e56089 100644
@@ -24,7 +24,7 @@ top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CFLAGS			+= -D_LARGEFILE64_SOURCE
+CFLAGS			+= -D_LARGEFILE64_SOURCE -Wall
 LDLIBS			+= -lrt -lpthread
 
 INSTALL_TARGETS		:= rwtest
Signature · 12 lines
1.7.4


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#11 lore raw
In reply to Alex Elder

Hi!
Commited, thanks.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list