Skip to contentSkip to conversation

add types for functions in fs-bench

PATCH In review Cyril Hrubis 1 participant 2 messages Apr 26, 2010 – Jul 8, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add types for functions in fs-bench

Hi!
Attached patch adds types for functions in sources for fs-bench just because when function doesn't have return type it defaults to int and this causes problems (for example when doing return from such function without value).

Side note:

The code quality for fs-bench is very poor, there is no documentation and the scripts are broken (mostly wrongly hardcoded paths). IMHO these tests are not worth fixing and candidate for removal.

Signature · 2 lines
Cyril Hrubis
[email protected]
testcases/kernel/fs/fs-bench/create-files.c +7 -4
Index: ltp-full-20100228/testcases/kernel/fs/fs-bench/create-files.c
===================================================================
@@ -19,7 +19,7 @@ static int filecount=0;
 extern int box_muler(int, int);
 
 int startc=0;
-main(int ac,char *av[])
+int main(int ac,char *av[])
 {
   int i=0;
   int j=0;
@@ -75,14 +75,17 @@ end:
 
 int showchar[]={124,47,45,92,124,47,45,92};
 static int mkdir_counter=0;
-makedir(char *dir1)
+
+void makedir(char *dir1)
 {
   if (mkdir(dir1, S_IRWXU) < 0) {
     perror(dir1);
     exit(1);
   }
 }
-changedir(char *dir) {
+
+void changedir(char *dir)
+{
   if ( chdir(dir) < 0 ) {
     perror(dir);
     exit(1);
@@ -90,7 +93,7 @@ changedir(char *dir) {
 }
 
 
-create_file(char *filename)
+void create_file(char *filename)
 {
   int fd;
   int randomsize;
testcases/kernel/fs/fs-bench/random-access-del-create.c +3 -4
Index: ltp-full-20100228/testcases/kernel/fs/fs-bench/random-access-del-create.c
===================================================================
@@ -24,8 +24,7 @@ int cfilecount=0;
 int dfilecount=0;
 int errorcount=0;
 
-int
-main(int ac, char **av)
+int main(int ac, char **av)
 {
   int r;
   char fname[1024];
@@ -92,7 +91,7 @@ void create_or_delete(char *fname)
   }
 }
 
-create_file(char *filename)
+int create_file(char *filename)
 {
   int fd;
   int randomsize;
@@ -117,7 +116,7 @@ create_file(char *filename)
 #include <sys/stat.h>
 #include <unistd.h>
 
-delete_file(char *filename)
+int delete_file(char *filename)
 {
   struct stat buf;
   int st;
testcases/kernel/fs/fs-bench/random-access.c +2 -2
Index: ltp-full-20100228/testcases/kernel/fs/fs-bench/random-access.c
===================================================================
@@ -16,7 +16,7 @@ int openlog[2]={0,0};
 #define MAXNUM 0x100000
 
 int nullfd;
-main(int ac, char **av)
+int main(int ac, char **av)
 {
   int fd;
   int r;
@@ -62,7 +62,7 @@ main(int ac, char **av)
 }
 
 #define BUFS 8192
-open_read_close(char *fname)
+void open_read_close(char *fname)
 {
   int fd;
   char buf[BUFS];
testcases/kernel/fs/fs-bench/random-del-create.c +3 -3
Index: ltp-full-20100228/testcases/kernel/fs/fs-bench/random-del-create.c
===================================================================
@@ -24,7 +24,7 @@ int cfilecount=0;
 int dfilecount=0;
 int errorcount=0;
 
-main(int ac, char **av)
+int main(int ac, char **av)
 {
   int r;
   char fname[1024];
@@ -91,7 +91,7 @@ void create_or_delete(char *fname)
   }
 }
 
-create_file(char *filename)
+int create_file(char *filename)
 {
   int fd;
   int randomsize;
@@ -116,7 +116,7 @@ create_file(char *filename)
 #include <sys/stat.h>
 #include <unistd.h>
 
-delete_file(char *filename)
+int delete_file(char *filename)
 {
   struct stat buf;
   int st;

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to a message not in the archive

Hi!

Quoted 7 lines
Quoted 7 lines

Attached patch adds types for functions in sources for fs-bench just because when function doesn't have return type it defaults to int and this causes problems (for example when doing return from such function without value).

Quoted 7 lines
Quoted 5 lines

Side note:

The code quality for fs-bench is very poor, there is no documentation and the scripts are broken (mostly wrongly hardcoded paths). IMHO these tests are not worth fixing and candidate for removal.

Please provide a build log.

Okay apparently I've missed some "unused variable" and "implicit function declaration" warnings. Attached patch fixes all compilation issues (has previous two merged) but still at least the test scripts are broken.

Signature · 2 lines
Cyril Hrubis
[email protected]
testcases/kernel/fs/fs-bench/boxmuler.c +3 -0
index 89ee941..0609335 100644
@@ -1,5 +1,8 @@
 #include <math.h>
+#include <stdlib.h>
+
 #define M_2PI (M_PI*2)
+
 int box_muler(int min, int max)
 {
   double u1,u2,z;
testcases/kernel/fs/fs-bench/create-files.c +11 -5
index 88ea202..ec54bb8 100644
@@ -15,11 +15,14 @@
 char wbuf[MAXFSIZE];
 static int filecount=0;
 
+void makedir(char *dir1);
+void changedir(char *dir);
+void create_file(char *filename);
 
 extern int box_muler(int, int);
 
 int startc=0;
-main(int ac,char *av[])
+int main(int ac,char *av[])
 {
   int i=0;
   int j=0;
@@ -71,18 +74,21 @@ main(int ac,char *av[])
 end:
   fprintf(stderr,"\nTotal create files: %d\n",filecount);
   printf("Done\n");
+  return 0;
 }
 
 int showchar[]={124,47,45,92,124,47,45,92};
-static int mkdir_counter=0;
-makedir(char *dir1)
+
+void makedir(char *dir1)
 {
   if (mkdir(dir1, S_IRWXU) < 0) {
     perror(dir1);
     exit(1);
   }
 }
-changedir(char *dir) {
+
+void changedir(char *dir)
+{
   if ( chdir(dir) < 0 ) {
     perror(dir);
     exit(1);
@@ -90,7 +96,7 @@ changedir(char *dir) {
 }
 
 
-create_file(char *filename)
+void create_file(char *filename)
 {
   int fd;
   int randomsize;
testcases/kernel/fs/fs-bench/random-access-del-create.c +10 -5
index 3322d92..fdfc71f 100644
@@ -20,12 +20,14 @@ int openlog[2]={0,0};
 extern int box_muler(int, int);
 extern void create_or_delete(char *);
 
+int delete_file(char *filename);
+int create_file(char *filename);
+
 int cfilecount=0;
 int dfilecount=0;
 int errorcount=0;
 
-int
-main(int ac, char **av)
+int main(int ac, char **av)
 {
   int r;
   char fname[1024];
@@ -73,7 +75,6 @@ static int disk_space_pool=0;
 void create_or_delete(char *fname)
 {
   int r;
-  int fsize;
 
   r = (random() & 1);
   if ( r && disk_space_pool > POOLDISKSPACE) {
@@ -92,7 +93,7 @@ void create_or_delete(char *fname)
   }
 }
 
-create_file(char *filename)
+int create_file(char *filename)
 {
   int fd;
   int randomsize;
@@ -112,12 +113,14 @@ create_file(char *filename)
   cfilecount++;
   disk_space_pool -= randomsize;
   close(fd);
+
+  return 0;
 }
 
 #include <sys/stat.h>
 #include <unistd.h>
 
-delete_file(char *filename)
+int delete_file(char *filename)
 {
   struct stat buf;
   int st;
@@ -132,4 +135,6 @@ delete_file(char *filename)
     return(-1);
   }
   dfilecount++;
+
+  return 0;
 }
testcases/kernel/fs/fs-bench/random-access.c +5 -3
index e2f8536..f5eb6a2 100644
@@ -15,10 +15,12 @@ int openlog[2]={0,0};
 
 #define MAXNUM 0x100000
 
+void open_read_close(char *fname);
+
 int nullfd;
-main(int ac, char **av)
+
+int main(int ac, char **av)
 {
-  int fd;
   int r;
   char fname[1024];
   time_t t;
@@ -62,7 +64,7 @@ main(int ac, char **av)
 }
 
 #define BUFS 8192
-open_read_close(char *fname)
+void open_read_close(char *fname)
 {
   int fd;
   char buf[BUFS];
testcases/kernel/fs/fs-bench/random-del-create.c +5 -3
index a1fc8b8..70ddf32 100644
@@ -24,7 +24,7 @@ int cfilecount=0;
 int dfilecount=0;
 int errorcount=0;
 
-main(int ac, char **av)
+int main(int ac, char **av)
 {
   int r;
   char fname[1024];
@@ -91,7 +91,7 @@ void create_or_delete(char *fname)
   }
 }
 
-create_file(char *filename)
+int create_file(char *filename)
 {
   int fd;
   int randomsize;
@@ -111,12 +111,13 @@ create_file(char *filename)
   cfilecount++;
   disk_space_pool -= randomsize;
   close(fd);
+  return 0;
 }
 
 #include <sys/stat.h>
 #include <unistd.h>
 
-delete_file(char *filename)
+int delete_file(char *filename)
 {
   struct stat buf;
   int st;
@@ -131,4 +132,5 @@ delete_file(char *filename)
     return(-1);
   }
   dfilecount++;
+  return 0;
 }

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -c -o create-files.o create-files.c create-files.c:23: warning: return type defaults to 'int'
create-files.c: In function 'main':
create-files.c:48: warning: implicit declaration of function 'makedir'
create-files.c:49: warning: implicit declaration of function 'changedir'
create-files.c:60: warning: implicit declaration of function 'create_file'
create-files.c: At top level:
create-files.c:79: warning: return type defaults to 'int'
create-files.c:85: warning: return type defaults to 'int'
create-files.c:94: warning: return type defaults to 'int'
create-files.c: In function 'create_file':
create-files.c:112: warning: control reaches end of non-void function
create-files.c: In function 'changedir':
create-files.c:90: warning: control reaches end of non-void function
create-files.c: In function 'makedir':
create-files.c:84: warning: control reaches end of non-void function
create-files.c: In function 'main':
create-files.c:74: warning: control reaches end of non-void function
create-files.c: At top level:
create-files.c:77: warning: 'mkdir_counter' defined but not used
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -c -o boxmuler.o boxmuler.c boxmuler.c: In function 'box_muler':
boxmuler.c:16: warning: implicit declaration of function 'random'
gcc -L../../../../lib create-files.o boxmuler.o -lm -o create-files
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -L../../../../lib random-access.c -lm -o random-access
random-access.c:20: warning: return type defaults to 'int'
random-access.c: In function 'main':
random-access.c:57: warning: implicit declaration of function 'open_read_close'
random-access.c:21: warning: unused variable 'fd'
random-access.c: At top level:
random-access.c:66: warning: return type defaults to 'int'
random-access.c: In function 'open_read_close':
random-access.c:74: warning: 'return' with no value, in function returning non-void
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -c -o random-access-del-create.o random-access-del-create.c random-access-del-create.c: In function 'create_or_delete':
random-access-del-create.c:81: warning: implicit declaration of function 'create_file'
random-access-del-create.c:84: warning: implicit declaration of function 'delete_file'
random-access-del-create.c:76: warning: unused variable 'fsize'
random-access-del-create.c: At top level:
random-access-del-create.c:96: warning: return type defaults to 'int'
random-access-del-create.c:121: warning: return type defaults to 'int'
random-access-del-create.c: In function 'delete_file':
random-access-del-create.c:135: warning: control reaches end of non-void function
random-access-del-create.c: In function 'create_file':
random-access-del-create.c:115: warning: control reaches end of non-void function
gcc -L../../../../lib random-access-del-create.o boxmuler.o -lm -o random-access-del-create

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall  -I../../../../include -I../../../../include  -c -o create-files.o create-files.c
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall  -I../../../../include -I../../../../include  -c -o boxmuler.o boxmuler.c

gcc -L../../../../lib create-files.o boxmuler.o -lm -o create-files
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -L../../../../lib random-access.c -lm -o random-access
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -I../../../../include -I../../../../include -c -o random-access-del-create.o random-access-del-create.c
gcc -L../../../../lib random-access-del-create.o boxmuler.o -lm -o random-access-del-create

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list