[rtems commit] Fixed warnings and minor bugs

Sebastian Huber sebh at rtems.org
Wed Feb 8 15:05:50 UTC 2012


Module:    rtems
Branch:    master
Commit:    28860ec03c339eb936205cd7750b0e1584981521
Changeset: http://git.rtems.org/rtems/commit/?id=28860ec03c339eb936205cd7750b0e1584981521

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Feb  8 15:57:04 2012 +0100

Fixed warnings and minor bugs

 o Due to the usual integer propagation rules care must be taken in case
   off_t is involved.
 o Use the effective UID and GID consistently.

---

 testsuites/fstests/fserror/test.c              |   10 +++---
 testsuites/fstests/fslink/test.c               |    2 +-
 testsuites/fstests/fspatheval/test.c           |    8 ++--
 testsuites/fstests/fspermission/test.c         |   18 ++++------
 testsuites/fstests/fsrdwr/init.c               |   42 +++++++++++++-----------
 testsuites/fstests/fssymlink/test.c            |    4 +-
 testsuites/fstests/fstime/test.c               |    2 +-
 testsuites/fstests/imfs_support/fs_support.c   |    1 +
 testsuites/fstests/mdosfs_support/fs_support.c |    1 +
 testsuites/fstests/mimfs_support/fs_support.c  |    1 +
 testsuites/fstests/mrfs_support/fs_support.c   |    1 +
 testsuites/fstests/support/fstest.h            |    1 +
 testsuites/fstests/support/fstest_support.c    |    2 +-
 13 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/testsuites/fstests/fserror/test.c b/testsuites/fstests/fserror/test.c
index 7c48024..5e43a9e 100644
--- a/testsuites/fstests/fserror/test.c
+++ b/testsuites/fstests/fserror/test.c
@@ -26,7 +26,7 @@
 #include "fstest.h"
 #include "pmacros.h"
 
-void open_mkdir_error (void)
+static void open_mkdir_error (void)
 {
   int fd;
   int status;
@@ -107,7 +107,7 @@ void open_mkdir_error (void)
 
 }
 
-void rename_error (void)
+static void rename_error (void)
 {
 
   int fd;
@@ -192,7 +192,7 @@ void rename_error (void)
   rtems_test_assert (status == 0);
 }
 
-void truncate_error (void)
+static void truncate_error (void)
 {
 
   int fd;
@@ -231,7 +231,7 @@ void truncate_error (void)
 }
 
 
-void rmdir_unlink_error (void)
+static void rmdir_unlink_error (void)
 {
   int status;
   int fd;
@@ -304,7 +304,7 @@ void rmdir_unlink_error (void)
 
 }
 
-void rdwr_error (void)
+static void rdwr_error (void)
 {
 
   int status;
diff --git a/testsuites/fstests/fslink/test.c b/testsuites/fstests/fslink/test.c
index fd30362..b2e062c 100644
--- a/testsuites/fstests/fslink/test.c
+++ b/testsuites/fstests/fslink/test.c
@@ -30,7 +30,7 @@
 /*
  * Test if the successful call works as expect
  */
-void link_test01 (void)
+static void link_test01 (void)
 {
   char *name0 = "t0";
   char *name1 = "t1";
diff --git a/testsuites/fstests/fspatheval/test.c b/testsuites/fstests/fspatheval/test.c
index 9ac61b3..9df57f5 100644
--- a/testsuites/fstests/fspatheval/test.c
+++ b/testsuites/fstests/fspatheval/test.c
@@ -27,7 +27,7 @@
 
 #define BUF_SIZE 100
 
-void make_multiple_files (char **files,int is_directory)
+static void make_multiple_files (char **files,int is_directory)
 {
   int i;
   int status;
@@ -54,7 +54,7 @@ void make_multiple_files (char **files,int is_directory)
   puts ("");
 }
 
-void remove_multiple_files (char **files,int is_directory)
+static void remove_multiple_files (char **files,int is_directory)
 {
   int i;
   int status;
@@ -83,7 +83,7 @@ void remove_multiple_files (char **files,int is_directory)
   puts ("");
 }
 
-void path_eval_test01 (void)
+static void path_eval_test01 (void)
 {
   char *valid_path[] = {
     "/test1/",
@@ -150,7 +150,7 @@ void path_eval_test01 (void)
   remove_multiple_files(valid_name,0);
 
 }
-void path_eval_test02(void )
+static void path_eval_test02(void )
 {
 
   int status;
diff --git a/testsuites/fstests/fspermission/test.c b/testsuites/fstests/fspermission/test.c
index 7432424..7b9e1c2 100644
--- a/testsuites/fstests/fspermission/test.c
+++ b/testsuites/fstests/fspermission/test.c
@@ -30,7 +30,7 @@
 /*
  *  Test the umask
  */
-void umask_test01(void )
+static void umask_test01(void )
 {
 
   mode_t previous_cmask;
@@ -158,7 +158,7 @@ void umask_test01(void )
 /*
  * Check the file mode in file and directory
  */
-void test_premission01(void )
+static void test_premission01(void )
 {
   mode_t tmp_mode;
   struct stat statbuf;
@@ -196,11 +196,9 @@ void test_premission01(void )
   status=chdir(wd);
   rtems_test_assert(status==0);
 
-  status=setgid(group_id);
-  rtems_test_assert(status==0);
   status=seteuid(user_id);
   rtems_test_assert(status==0);
-  status=seteuid(user_id);
+  status=setegid(group_id);
   rtems_test_assert(status==0);
 
 
@@ -349,7 +347,7 @@ void test_premission01(void )
   status=seteuid(0);
   rtems_test_assert(status==0);
 
-  status=setgid(another_group_id);
+  status=setegid(another_group_id);
   rtems_test_assert(status==0);
 
   status=seteuid(another_user_id);
@@ -376,7 +374,7 @@ void test_premission01(void )
    */
   status=seteuid(0);
   rtems_test_assert(status==0);
-  status=setgid(0);
+  status=setegid(0);
   rtems_test_assert(status==0);
   free(data_buf);
 
@@ -387,7 +385,7 @@ void test_premission01(void )
 /*
  * Test chown and chmod
  */
-void  test_premission02(void )
+static void  test_premission02(void )
 {
   struct stat statbuf;
   int status = 0;
@@ -459,7 +457,7 @@ void  test_premission02(void )
   status=chdir("..");
   rtems_test_assert(status==0);
 }
-void root_test(void )
+static void root_test(void )
 {
   int fd;
   int sc;
@@ -469,7 +467,7 @@ void root_test(void )
   rtems_test_assert(sc==0);
 
   fd=open("test",O_RDONLY);
-  rtems_test_assert(fd!=-1);
+  rtems_test_assert(fd==-1);
 }
 
 void test(void )
diff --git a/testsuites/fstests/fsrdwr/init.c b/testsuites/fstests/fsrdwr/init.c
index aa5404a..ef2b02a 100644
--- a/testsuites/fstests/fsrdwr/init.c
+++ b/testsuites/fstests/fsrdwr/init.c
@@ -32,7 +32,7 @@ const char *databuf =
   "4Happy days are here again.5Happy days are here again.6Happy days are here "
   "again.7Happy days are here again.";
 
-void
+static void
 read_write_test (void)
 {
 
@@ -184,7 +184,7 @@ read_write_test (void)
   rtems_test_assert (status == 0);
 }
 
-void
+static void
 truncate_test03 (void)
 {
 
@@ -282,12 +282,12 @@ truncate_test03 (void)
   rtems_test_assert (status == 0);
 }
 
-void
+static void
 lseek_test (void)
 {
   int fd;
   int status;
-  char *name01 = "test_name01";
+  const char *name01 = "test_name01";
   struct stat statbuf;
 
   int n;
@@ -295,7 +295,7 @@ lseek_test (void)
 
   size_t len = strlen (databuf);
   off_t pos;
-  int total_written = 0;
+  ssize_t total_written = 0;
 
   char *readbuf;
   mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
@@ -366,15 +366,18 @@ lseek_test (void)
   pos = lseek (fd, 0, SEEK_CUR);
   rtems_test_assert (pos == total_written + 1);
 
-
-  status = close (fd);
-  rtems_test_assert (status == 0);
-
   /*
    * Check the file size
    */
-  status = stat (name01, &statbuf);
-  rtems_test_assert (statbuf.st_size == total_written);
+  status = fstat (fd, &statbuf);
+  rtems_test_assert (status == 0);
+  rtems_test_assert (statbuf.st_size == total_written + 1);
+
+  status = ftruncate (fd, total_written);
+  rtems_test_assert (status == 0);
+
+  status = close (fd);
+  rtems_test_assert (status == 0);
 
   /*
    * Open the file with O_RDONLY and check the lseek
@@ -393,7 +396,7 @@ lseek_test (void)
   rtems_test_assert (n == len);
   rtems_test_assert (!strncmp (databuf, readbuf, len));
 
-  pos = lseek (fd, -len, SEEK_CUR);
+  pos = lseek (fd, -(off_t) len, SEEK_CUR);
   rtems_test_assert (pos == 3 * len);
   n = read (fd, readbuf, len);
   rtems_test_assert (n == len);
@@ -410,7 +413,7 @@ lseek_test (void)
   rtems_test_assert (n == len);
   rtems_test_assert (strncmp (databuf, readbuf, len) != 0);
 
-  pos = lseek (fd, -len, SEEK_END);
+  pos = lseek (fd, -(off_t) len, SEEK_END);
   n = read (fd, readbuf, 2 * len);
   rtems_test_assert (n == len);
   rtems_test_assert (!strncmp (databuf, readbuf, len));
@@ -436,7 +439,7 @@ lseek_test (void)
   rtems_test_assert (n == len);
   rtems_test_assert (!strncmp (databuf, readbuf, len));
 
-  pos = lseek (fd, -len, SEEK_CUR);
+  pos = lseek (fd, -(off_t) len, SEEK_CUR);
   rtems_test_assert (pos == 3 * len);
   n = read (fd, readbuf, len);
   rtems_test_assert (n == len);
@@ -458,7 +461,7 @@ lseek_test (void)
   /*
    * Use SEEK_END
    */
-  pos = lseek (fd, -len, SEEK_END);
+  pos = lseek (fd, -(off_t) len, SEEK_END);
   n = read (fd, readbuf, 2 * len);
   rtems_test_assert (n == len);
   rtems_test_assert (!strncmp (databuf, readbuf, len));
@@ -468,14 +471,14 @@ lseek_test (void)
   /*
    * Write the zero to the end of file.
    */
-  pos = lseek (fd, -len, SEEK_END);
-  rtems_test_assert (pos == total_written - len);
+  pos = lseek (fd, -(off_t) len, SEEK_END);
+  rtems_test_assert (pos == (off_t) total_written - (off_t) len);
   n = write (fd, readbuf, len);
   rtems_test_assert (n == len);
   /*
    * Verify it
    */
-  pos = lseek (fd, total_written - len, SEEK_SET);
+  pos = lseek (fd, (off_t) total_written - (off_t) len, SEEK_SET);
   n = read (fd, readbuf, len);
   rtems_test_assert (n == len);
   for (i = 0; i < n; i++) {
@@ -485,7 +488,7 @@ lseek_test (void)
   /*
    * Write the zero to the beginning of file.
    */
-  pos = lseek (fd, -total_written, SEEK_END);
+  pos = lseek (fd, -(off_t) total_written, SEEK_END);
   rtems_test_assert (pos == 0);
   n = write (fd, readbuf, len);
   rtems_test_assert (n == len);
@@ -527,4 +530,5 @@ test (void)
 {
   read_write_test ();
   lseek_test ();
+  truncate_test03 ();
 }
diff --git a/testsuites/fstests/fssymlink/test.c b/testsuites/fstests/fssymlink/test.c
index 84329e2..e009907 100644
--- a/testsuites/fstests/fssymlink/test.c
+++ b/testsuites/fstests/fssymlink/test.c
@@ -32,7 +32,7 @@
  * Test the function of symlink
  */
 
-void symlink_test01(void )
+static void symlink_test01(void )
 {
   int   fd;
   char* file01="file";
@@ -128,7 +128,7 @@ void symlink_test01(void )
 /*
  *  symlink loop error test
  */
-void symlink_loop_error_test(void )
+static void symlink_loop_error_test(void )
 {
   char* file01="file01";
   char* file02="file02";
diff --git a/testsuites/fstests/fstime/test.c b/testsuites/fstests/fstime/test.c
index 7f570b1..fe6bcee 100644
--- a/testsuites/fstests/fstime/test.c
+++ b/testsuites/fstests/fstime/test.c
@@ -28,7 +28,7 @@
 #include "fstest.h"
 #include "pmacros.h"
 
-void time_test01 (void)
+static void time_test01 (void)
 {
   struct stat statbuf;
   struct utimbuf timbuf;
diff --git a/testsuites/fstests/imfs_support/fs_support.c b/testsuites/fstests/imfs_support/fs_support.c
index 814a847..b7a7357 100644
--- a/testsuites/fstests/imfs_support/fs_support.c
+++ b/testsuites/fstests/imfs_support/fs_support.c
@@ -16,6 +16,7 @@
 #include <sys/stat.h>
 
 #include "fstest.h"
+#include "fstest_support.h"
 
 void
 test_initialize_filesystem (void)
diff --git a/testsuites/fstests/mdosfs_support/fs_support.c b/testsuites/fstests/mdosfs_support/fs_support.c
index 96f8848..06dbb61 100644
--- a/testsuites/fstests/mdosfs_support/fs_support.c
+++ b/testsuites/fstests/mdosfs_support/fs_support.c
@@ -23,6 +23,7 @@
 
 #include "ramdisk_support.h"
 #include "fstest.h"
+#include "fstest_support.h"
 
 #define BLOCK_SIZE 512
 
diff --git a/testsuites/fstests/mimfs_support/fs_support.c b/testsuites/fstests/mimfs_support/fs_support.c
index 6e87686..b835cb9 100644
--- a/testsuites/fstests/mimfs_support/fs_support.c
+++ b/testsuites/fstests/mimfs_support/fs_support.c
@@ -18,6 +18,7 @@
 #include <rtems/libio.h>
 
 #include "fstest.h"
+#include "fstest_support.h"
 
 void
 test_initialize_filesystem (void)
diff --git a/testsuites/fstests/mrfs_support/fs_support.c b/testsuites/fstests/mrfs_support/fs_support.c
index ca779aa..ec57e18 100644
--- a/testsuites/fstests/mrfs_support/fs_support.c
+++ b/testsuites/fstests/mrfs_support/fs_support.c
@@ -23,6 +23,7 @@
 #include "ramdisk_support.h"
 
 #include "fstest.h"
+#include "fstest_support.h"
 
 #define BLOCK_SIZE (512)
 
diff --git a/testsuites/fstests/support/fstest.h b/testsuites/fstests/support/fstest.h
index 6342f75..d3fabac 100644
--- a/testsuites/fstests/support/fstest.h
+++ b/testsuites/fstests/support/fstest.h
@@ -50,6 +50,7 @@
      FS_FAIL();\
    } while (0)
 
+void test(void);
 
 #define BASE_FOR_TEST "/mnt"
 #endif
diff --git a/testsuites/fstests/support/fstest_support.c b/testsuites/fstests/support/fstest_support.c
index 5d8dd4c..239bdb9 100644
--- a/testsuites/fstests/support/fstest_support.c
+++ b/testsuites/fstests/support/fstest_support.c
@@ -34,7 +34,7 @@
 
 
 /* Break out of a chroot() environment in C */
-void break_out_of_chroot(void)
+static void break_out_of_chroot(void)
 {
 
   int dir_fd;       /* File descriptor to directory */




More information about the vc mailing list