mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-24 06:55:44 +08:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "fstest.h"
|
||||
#include "fstest_support.h"
|
||||
|
||||
void
|
||||
test_initialize_filesystem (void)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "ramdisk_support.h"
|
||||
#include "fstest.h"
|
||||
#include "fstest_support.h"
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <rtems/libio.h>
|
||||
|
||||
#include "fstest.h"
|
||||
#include "fstest_support.h"
|
||||
|
||||
void
|
||||
test_initialize_filesystem (void)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ramdisk_support.h"
|
||||
|
||||
#include "fstest.h"
|
||||
#include "fstest_support.h"
|
||||
|
||||
#define BLOCK_SIZE (512)
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
FS_FAIL();\
|
||||
} while (0)
|
||||
|
||||
void test(void);
|
||||
|
||||
#define BASE_FOR_TEST "/mnt"
|
||||
#endif
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user