* [LTP] [PATCH 5/6] ltp: use C function prototypes in "iogen.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 "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.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
testcases/kernel/fs/doio/iogen.c | 61 +++++++++++++++-----------------------
1 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/testcases/kernel/fs/doio/iogen.c b/testcases/kernel/fs/doio/iogen.c
index 4f46099..167edbd 100644
--- a/testcases/kernel/fs/doio/iogen.c
+++ b/testcases/kernel/fs/doio/iogen.c
@@ -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
+}
--
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 5/6] ltp: use C function prototypes in "iogen.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 5/6] ltp: use C function prototypes in "iogen.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 "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.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
testcases/kernel/fs/doio/iogen.c | 61 +++++++++++++++-----------------------
1 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/testcases/kernel/fs/doio/iogen.c b/testcases/kernel/fs/doio/iogen.c
index 4f46099..167edbd 100644
--- a/testcases/kernel/fs/doio/iogen.c
+++ b/testcases/kernel/fs/doio/iogen.c
@@ -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
+}
--
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 5/6] ltp: use C function prototypes in "iogen.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 5/6] ltp: use C function prototypes in "iogen.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