* [LTP] [PATCH 4/6] ltp: use C function prototypes in "growfiles.c"
@ 2011-04-04 12:08 Alex Elder
0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2011-04-04 12:08 UTC (permalink / raw)
To: ltp-list
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.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
testcases/kernel/fs/doio/growfiles.c | 121 ++++++++++++++-------------------
1 files changed, 51 insertions(+), 70 deletions(-)
diff --git a/testcases/kernel/fs/doio/growfiles.c b/testcases/kernel/fs/doio/growfiles.c
index f85d47e..2bb21bd 100644
--- a/testcases/kernel/fs/doio/growfiles.c
+++ b/testcases/kernel/fs/doio/growfiles.c
@@ -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
--
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread* [LTP] [PATCH 0/6] ltp: kill off some compile warnings
@ 2011-04-01 22:01 Alex Elder
2011-04-01 22:01 ` [LTP] [PATCH 1/6] ltp: fix databinchk() definition Alex Elder
0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2011-04-01 22:01 UTC (permalink / raw)
To: ltp-list
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
* [LTP] [PATCH 1/6] ltp: fix databinchk() definition
2011-04-01 22:01 [LTP] [PATCH 0/6] ltp: kill off some compile warnings Alex Elder
@ 2011-04-01 22:01 ` Alex Elder
2011-04-01 22:01 ` [LTP] [PATCH 4/6] ltp: use C function prototypes in "growfiles.c" Alex Elder
0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2011-04-01 22:01 UTC (permalink / raw)
To: ltp-list
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.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
include/databin.h | 2 +-
lib/databin.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/databin.h b/include/databin.h
index c168799..93c3863 100644
--- a/include/databin.h
+++ b/include/databin.h
@@ -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
diff --git a/lib/databin.c b/lib/databin.c
index 6659ccf..c0f4307 100644
--- a/lib/databin.c
+++ b/lib/databin.c
@@ -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) {
--
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread* [LTP] [PATCH 4/6] ltp: use C function prototypes in "growfiles.c"
2011-04-01 22:01 ` [LTP] [PATCH 1/6] ltp: fix databinchk() definition Alex Elder
@ 2011-04-01 22:01 ` Alex Elder
0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2011-04-01 22:01 UTC (permalink / raw)
To: ltp-list
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.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
testcases/kernel/fs/doio/growfiles.c | 121 ++++++++++++++-------------------
1 files changed, 51 insertions(+), 70 deletions(-)
diff --git a/testcases/kernel/fs/doio/growfiles.c b/testcases/kernel/fs/doio/growfiles.c
index f85d47e..2bb21bd 100644
--- a/testcases/kernel/fs/doio/growfiles.c
+++ b/testcases/kernel/fs/doio/growfiles.c
@@ -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
--
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-04 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-04 12:08 [LTP] [PATCH 4/6] ltp: use C function prototypes in "growfiles.c" Alex Elder
-- strict thread matches above, loose matches on Subject: below --
2011-04-01 22:01 [LTP] [PATCH 0/6] ltp: kill off some compile warnings Alex Elder
2011-04-01 22:01 ` [LTP] [PATCH 1/6] ltp: fix databinchk() definition Alex Elder
2011-04-01 22:01 ` [LTP] [PATCH 4/6] ltp: use C function prototypes in "growfiles.c" Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox