[Ocfs2-users] [PATCH 04/10] Fix compilation issues with the programs unused variables, incorrect printf format, char array usage etc.
zren at suse.com
zren at suse.com
Wed Sep 9 23:54:44 PDT 2015
From: Goldwyn Rodrigues <rgoldwyn at suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com>
Reviewed-by: Eric Ren <zren at suse.com>
---
programs/aio-stress/aio-stress.c | 17 +++--
.../check_file_size_limits.c | 2 +-
programs/directio_test/directio.h | 3 +
programs/discontig_bg_test/gen_extents.c | 3 +-
programs/extend_and_write/verify.c | 1 +
programs/extendo/extendo.c | 4 +-
programs/inline-data/inline-data-utils.c | 8 +--
programs/inline-data/inline-data.c | 5 +-
programs/inline-data/inline-dirs-utils.c | 4 +-
programs/inline-data/inline-dirs.c | 10 +--
programs/multi_node_mmap/multi_mmap.c | 2 -
programs/quota_tests/quota_multi_tests.c | 80 ++++++++++------------
programs/reserve_space/reserve_space.c | 4 +-
programs/truncate/verify_truncate.c | 6 +-
programs/xattr_tests/xattr-test-utils.c | 30 ++++----
programs/xattr_tests/xattr-test.c | 13 ++--
16 files changed, 97 insertions(+), 95 deletions(-)
diff --git a/programs/aio-stress/aio-stress.c b/programs/aio-stress/aio-stress.c
index 91af264..fd38b66 100644
--- a/programs/aio-stress/aio-stress.c
+++ b/programs/aio-stress/aio-stress.c
@@ -1170,7 +1170,7 @@ restart:
if (t->stage_mb_trans && t->num_files > 0) {
double seconds = time_since_now(&stage_time);
- fprintf(stderr, "thread %d %s totals (%.2f MB/s) %.2f MB in %.2fs\n",
+ fprintf(stderr, "thread %ld %s totals (%.2f MB/s) %.2f MB in %.2fs\n",
t - global_thread_info, this_stage, t->stage_mb_trans/seconds,
t->stage_mb_trans, seconds);
}
@@ -1452,16 +1452,21 @@ int main(int ac, char **av)
if (file_size < num_contexts * context_offset) {
fprintf(stderr, "file size %Lu too small for %d contexts\n",
- file_size, num_contexts);
+ (unsigned long long)file_size, num_contexts);
exit(1);
}
- fprintf(stderr, "file size %LuMB, record size %luKB, depth %d, ios per iteration %d\n", file_size / (1024 * 1024), rec_len / 1024, depth, io_iter);
+ fprintf(stderr, "file size %LuMB, record size %luKB, depth %d, ios "
+ "per iteration %d\n",
+ (unsigned long long) file_size / (1024 * 1024),
+ rec_len / 1024, depth, io_iter);
fprintf(stderr, "max io_submit %d, buffer alignment set to %luKB\n",
max_io_submit, (page_size_mask + 1)/1024);
- fprintf(stderr, "threads %d files %d contexts %d context offset %LuMB verification %s\n",
- num_threads, num_files, num_contexts,
- context_offset / (1024 * 1024), verify ? "on" : "off");
+ fprintf(stderr, "threads %d files %d contexts %d context offset "
+ "%LuMB verification %s\n",
+ num_threads, num_files, num_contexts,
+ (unsigned long long) context_offset / (1024 * 1024),
+ verify ? "on" : "off");
/* open all the files and do any required setup for them */
for (i = optind ; i < ac ; i++) {
int thread_index;
diff --git a/programs/check_file_size_limits/check_file_size_limits.c b/programs/check_file_size_limits/check_file_size_limits.c
index 04664e2..22e69c7 100644
--- a/programs/check_file_size_limits/check_file_size_limits.c
+++ b/programs/check_file_size_limits/check_file_size_limits.c
@@ -220,7 +220,7 @@ static int write_at_largest_off(int fd, unsigned long long max_off)
int main(int argc, char **argv)
{
int fd, ret;
- unsigned int bbits = 0, cbits = 0;
+ int bbits = 0, cbits = 0;
char *fname = NULL;
unsigned long long max_off;
diff --git a/programs/directio_test/directio.h b/programs/directio_test/directio.h
index fa02b1c..f2fe228 100755
--- a/programs/directio_test/directio.h
+++ b/programs/directio_test/directio.h
@@ -26,6 +26,9 @@
#include <fcntl.h>
#include <signal.h>
#include <linux/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
#include <linux/limits.h>
#include <sys/time.h>
#include <sys/sem.h>
diff --git a/programs/discontig_bg_test/gen_extents.c b/programs/discontig_bg_test/gen_extents.c
index 8ce9ae2..ab4626a 100755
--- a/programs/discontig_bg_test/gen_extents.c
+++ b/programs/discontig_bg_test/gen_extents.c
@@ -68,6 +68,7 @@ int parse_opts(int argc, char **argv)
filesize = 0;
enable_multi_nodes = 0;
+ filename[0]='\0';
while (1) {
c = getopt(argc, argv, "f:l:c:k:mh:");
@@ -98,7 +99,7 @@ int parse_opts(int argc, char **argv)
}
}
- if (!filename) {
+ if (filename[0]=='\0') {
fprintf(stderr, "filename is a mandatory option\n");
usage();
}
diff --git a/programs/extend_and_write/verify.c b/programs/extend_and_write/verify.c
index 0dbb0ba..5c1d6c3 100644
--- a/programs/extend_and_write/verify.c
+++ b/programs/extend_and_write/verify.c
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/programs/extendo/extendo.c b/programs/extendo/extendo.c
index 399a7f0..825687e 100644
--- a/programs/extendo/extendo.c
+++ b/programs/extendo/extendo.c
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
printf("error %d: %s\n", errno, strerror(errno));
exit(1);
}
- printf("seek to end at offset %llu\n", off);
+ printf("seek to end at offset %llu\n", (unsigned long long)off);
strcpy(buf, "123456789");
ts.tv_sec = (wait/1000);
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
}
printf("write succeeded at offset %lld... sleeping %d ms...\n",
- off, wait);
+ (long long int) off, wait);
ret = nanosleep(&ts, &rem);
if (ret == -1) {
diff --git a/programs/inline-data/inline-data-utils.c b/programs/inline-data/inline-data-utils.c
index 0e1489e..9bec975 100644
--- a/programs/inline-data/inline-data-utils.c
+++ b/programs/inline-data/inline-data-utils.c
@@ -109,7 +109,6 @@ int extend_pattern(int fd, unsigned int old_size, unsigned int new_size)
{
int bytes = new_size - old_size;
int ret;
- int i;
memset(pattern + old_size, 0, bytes);
@@ -210,7 +209,8 @@ int write_at(int fd, const void *buf, size_t count, off_t offset)
}
if (ret != count) {
- fprintf(stderr, "Short write: wanted %d, got %d\n", count, ret);
+ fprintf(stderr, "Short write: wanted %lu, got %d\n",
+ (unsigned long) count, ret);
return -1;
}
@@ -432,7 +432,7 @@ int should_inlined_or_not(int is_inlined, int should_inlined, int test_no)
if (!is_inlined) {
fprintf(stderr, "After Test #%d, file %s should be "
"inlined here!\n", test_no, file_name);
- fprintf(stderr, "File(%s): i_size = %d,id_count = %d\n",
+ fprintf(stderr, "File(%s): i_size = %ld,id_count = %u\n",
file_name, i_size, id_count);
return -1;
}
@@ -441,7 +441,7 @@ int should_inlined_or_not(int is_inlined, int should_inlined, int test_no)
if (is_inlined) {
fprintf(stderr, "After Test #%d, file %s should be "
"extented here!\n", test_no, file_name);
- fprintf(stderr, "File(%s): i_size = %d,id_count = %d\n",
+ fprintf(stderr, "File(%s): i_size = %ld,id_count = %u\n",
file_name, i_size, id_count);
return -1;
diff --git a/programs/inline-data/inline-data.c b/programs/inline-data/inline-data.c
index 6bf40f7..13124d7 100644
--- a/programs/inline-data/inline-data.c
+++ b/programs/inline-data/inline-data.c
@@ -234,8 +234,8 @@ static int setup(int argc, char *argv[])
mount_point, WORK_PLACE);
mkdir(work_place, FILE_MODE);
- printf("BlockSize:\t\t%d\nMax Inline Data Size:\t%d\n"
- "ClusterSize:\t\t%d\nPageSize:\t\t%d\nWorkingPlace:\t\t%s\n\n",
+ printf("BlockSize:\t\t%u\nMax Inline Data Size:\t%d\n"
+ "ClusterSize:\t\t%lu\nPageSize:\t\t%lu\nWorkingPlace:\t\t%s\n\n",
blocksize, max_inline_size, clustersize, page_size, work_place);
return 0;
@@ -902,7 +902,6 @@ static int test_regular_file(int test_no)
test_num++;
}
-bail:
printf("All File I/O Tests Passed\n");
unlink(file_name);
diff --git a/programs/inline-data/inline-dirs-utils.c b/programs/inline-data/inline-dirs-utils.c
index e0d0545..3683452 100644
--- a/programs/inline-data/inline-dirs-utils.c
+++ b/programs/inline-data/inline-dirs-utils.c
@@ -572,7 +572,7 @@ void should_inlined_or_not(int is_inlined, int should_inlined, int test_no)
if (!is_inlined) {
fprintf(stderr, "After Test #%d, dir %s should be "
"inlined here!\n", test_no, dir_name);
- fprintf(stderr, "Dir(%s): i_size = %d,id_count = %d\n",
+ fprintf(stderr, "Dir(%s): i_size = %lu,id_count = %d\n",
dir_name, i_size, id_count);
exit(-1);
}
@@ -581,7 +581,7 @@ void should_inlined_or_not(int is_inlined, int should_inlined, int test_no)
if (is_inlined) {
fprintf(stderr, "After Test #%d, dir %s should be "
"extented here!\n", test_no, dir_name);
- fprintf(stderr, "Dir(%s): i_size = %d,id_count = %d\n",
+ fprintf(stderr, "Dir(%s): i_size = %lu,id_count = %d\n",
dir_name, i_size, id_count);
exit(-1);
diff --git a/programs/inline-data/inline-dirs.c b/programs/inline-data/inline-dirs.c
index d7a4510..0fb5fd6 100644
--- a/programs/inline-data/inline-dirs.c
+++ b/programs/inline-data/inline-dirs.c
@@ -309,7 +309,7 @@ static void run_large_dir_tests(void)
should_inlined_or_not(ret, 0, testno);
/*verify i_size should be one block size here*/
if (i_size != blocksize) {
- fprintf(stderr, "i_size should be %d,while it's % here!\n",
+ fprintf(stderr, "i_size should be %d,while it's %lu here!\n",
blocksize, i_size);
}
destroy_dir();
@@ -328,7 +328,7 @@ static void run_large_dir_tests(void)
should_inlined_or_not(ret, 0, testno);
/*verify i_size should be one block size here*/
if (i_size != blocksize * 2) {
- fprintf(stderr, "i_size should be %d,while it's % here!\n",
+ fprintf(stderr, "i_size should be %d,while it's %lu here!\n",
blocksize * 2, i_size);
}
destroy_dir();
@@ -454,7 +454,7 @@ static void del_semvalue(void)
static void run_concurrent_test(void)
{
int ret, rc;
- int i, j, status;
+ int i, status;
struct my_dirent *old_dirents;
key_t sem_key = IPC_PRIVATE, shm_key = IPC_PRIVATE;
@@ -556,7 +556,7 @@ static void run_concurrent_test(void)
static void run_multiple_test(void)
{
- int i, j, status;
+ int i, status;
pid_t pid;
int ret, rc;
@@ -658,7 +658,7 @@ static void setup(int argc, char *argv[])
snprintf(dir_name, 255, "%s/%s", work_place, dirent_name);
printf("BlockSize:\t\t%d\nMax Inline Data Size:\t%d\n"
- "ClusterSize:\t\t%d\nPageSize:\t\t%d\nWorkingPlace:\t\t%s\n"
+ "ClusterSize:\t\t%lu\nPageSize:\t\t%lu\nWorkingPlace:\t\t%s\n"
"NumOfMaxInlinedEntries:\t\t%d\n\n", blocksize, max_inline_size,
clustersize, page_size, work_place,
get_max_inlined_entries(max_inline_size));
diff --git a/programs/multi_node_mmap/multi_mmap.c b/programs/multi_node_mmap/multi_mmap.c
index 1ee4dd2..892fc98 100644
--- a/programs/multi_node_mmap/multi_mmap.c
+++ b/programs/multi_node_mmap/multi_mmap.c
@@ -443,12 +443,10 @@ static void write_verify_blocks(int fd)
{
int i;
unsigned int block;
- char *buf = mapped_area + (block*blocksize);
for(i = 0; i < num_blocks; i++) {
block = i;
- buf = mapped_area + (block * blocksize);
fill_with_expected_pattern(local_pattern, block);
if ((i % num_procs) == rank)
diff --git a/programs/quota_tests/quota_multi_tests.c b/programs/quota_tests/quota_multi_tests.c
index 350d3cb..7be3f22 100755
--- a/programs/quota_tests/quota_multi_tests.c
+++ b/programs/quota_tests/quota_multi_tests.c
@@ -523,7 +523,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
long i, file_index, rm_counts = 0;
struct if_dqblk s_dq, d_dq;
char username[USERNAME_SZ];
- int *inodes_removed;
+ int *inodes_removed = NULL;
MPI_Request request;
MPI_Status status;
@@ -532,7 +532,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
inodes_removed = (int *)malloc(sizeof(int) * isoftlimit * 2);
memset((void *)inodes_removed, 0, sizeof(int) * isoftlimit *2);
- snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
+ snprintf(username, USERNAME_SZ, "quota-user-rank%d-%ld", rank,
user_postfix);
add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
@@ -545,7 +545,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
s_dq.dqb_curspace = 0;
setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
} else
- snprintf(username, USERNAME_SZ, "quota-user-rank0-%d",
+ snprintf(username, USERNAME_SZ, "quota-user-rank0-%ld",
user_postfix);
/*
@@ -557,7 +557,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
o_uid = getuid();
seteuid(name2id(USER, username));
for (i = 0; i < isoftlimit * 2; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-quotafile-%ld",
workplace, username, i);
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
if (fd < 0) {
@@ -603,7 +603,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
while (rm_counts < rm_nums) {
i = get_rand(0, isoftlimit * 2 - 1);
- snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-quotafile-%ld",
workplace, username, i);
ret = unlink(filename);
if (ret < 0)
@@ -626,7 +626,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
file_index = 0;
while (file_index < isoftlimit * 2) {
if (!inodes_removed[file_index]) {
- snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-quotafile-%ld",
workplace, username, file_index);
ret = unlink(filename);
}
@@ -654,7 +654,7 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
char username[USERNAME_SZ];
- snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
+ snprintf(username, USERNAME_SZ, "quota-user-rank%d-%ld", rank,
user_postfix);
add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
@@ -676,7 +676,7 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
seteuid(name2id(USER, username));
for (i = 0; i <= isoftlimit ; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
if (fd < 0) {
@@ -695,7 +695,7 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
/*Grace time take effect from now*/
sleep(grace_seconds);
/*grace time expires,so should hit failure here*/
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, isoftlimit + 1);
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE)) > 0) {
close(fd);
@@ -706,7 +706,7 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
seteuid(o_uid);
for (i = 0; i <= isoftlimit; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
ret = unlink(filename);
if (ret < 0) {
@@ -722,11 +722,9 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
static void user_space_limit_test(long isoftlimit, long bsoftlimit, int user_postfix)
{
- int ret;
- long i;
- int fd;
+ int ret, fd;
int o_uid;
- struct if_dqblk s_dq, d_dq;
+ struct if_dqblk s_dq;
char *write_buf;
int writen_sz = 0;
long file_sz = 0;
@@ -822,7 +820,7 @@ static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_po
}
for (i = 0; i < isoftlimit * 2; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
if (!(i % 2)) {
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
@@ -837,12 +835,12 @@ static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_po
getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
if (d_dq.dqb_curinodes != i + 1)
abort_printf("Incorrect quota stats found,expected "
- "inode_num = %d,queried inode_num = %d.\n",
+ "inode_num = %ld,queried inode_num = %d.\n",
i + 1, d_dq.dqb_curinodes);
}
/*We definitely should hit falure here*/
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, isoftlimit * 2);
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE)) > 0) {
@@ -853,7 +851,7 @@ static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_po
/*cleanup*/
seteuid(o_uid);
for (i = 0; i < isoftlimit * 2; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
if (!(i % 2)) {
ret = unlink(filename);
@@ -879,10 +877,10 @@ static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_po
static void group_space_limit_test(long isoftlimit, long bsoftlimit,
long user_num, int grp_postfix)
{
- int ret, fd;
- long i, j;
+ int ret = 0, fd;
+ long i;
int o_uid, o_gid;
- struct if_dqblk s_dq, d_dq;
+ struct if_dqblk s_dq;
char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
char *write_buf;
@@ -908,7 +906,7 @@ static void group_space_limit_test(long isoftlimit, long bsoftlimit,
setegid(name2id(GROUP, groupname));
for (i = 0; i < user_num; i++) {
- snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+ snprintf(username, USERNAME_SZ, "%s-quotauser-%ld", groupname, i);
add_rm_user_group(USERADD_BIN, ADD, USER_IN_GROUP, username,
groupname);
getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
@@ -966,7 +964,7 @@ static void group_space_limit_test(long isoftlimit, long bsoftlimit,
setegid(o_gid);
for (i = 0; i < user_num; i++) {
- snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+ snprintf(username, USERNAME_SZ, "%s-quotauser-%ld", groupname, i);
snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-group-spacelimit",
workplace, hostname, username);
ret = unlink(filename);
@@ -990,7 +988,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
long user_num, int grp_postfix)
{
int ret, fd;
- long i, j;
+ long i;
int o_uid, o_gid;
int user_index;
struct if_dqblk s_dq, d_dq;
@@ -1011,7 +1009,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
setquota(QUOTAGROUP, device, name2id(GROUP, groupname), s_dq);
for (i = 0; i < user_num; i++) {
- snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+ snprintf(username, USERNAME_SZ, "%s-quotauser-%ld", groupname, i);
add_rm_user_group(USERADD_BIN, ADD, USER_IN_GROUP, username,
groupname);
getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
@@ -1031,7 +1029,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
user_index = i % user_num;
snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname,
user_index);
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
o_uid = getuid();
seteuid(name2id(USER, username));
@@ -1054,7 +1052,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
/*We definitely should hit falure here*/
user_index = (isoftlimit * 2) % user_num;
snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, user_index);
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, isoftlimit * 2);
o_uid = getuid();
seteuid(name2id(USER, username));
@@ -1071,7 +1069,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
user_index = i % user_num;
snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname,
user_index);
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
ret = unlink(filename);
if (ret < 0) {
@@ -1083,7 +1081,7 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
}
for (i = 0; i < user_num; i++) {
- snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+ snprintf(username, USERNAME_SZ, "%s-quotauser-%ld", groupname, i);
add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
}
@@ -1093,12 +1091,10 @@ static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
static void quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfix)
{
int ret, fd;
- long i, j;
- int o_uid, o_gid;
- int user_index;
+ long i;
+ int o_uid;
struct if_dqblk s_dq, d_dq;
-
- char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
+ char username[USERNAME_SZ];
snprintf(username, USERNAME_SZ, "quotauser-rank%d-%d", rank,
user_postfix);
@@ -1117,7 +1113,7 @@ static void quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfi
ret = seteuid(name2id(USER, username));
for (i = 0; i < isoftlimit; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
@@ -1143,7 +1139,7 @@ static void quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfi
d_dq.dqb_curinodes);
for (i = 0; i < isoftlimit; i++) {
- snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+ snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
workplace, hostname, username, i);
ret = unlink(filename);
if (ret < 0) {
@@ -1159,8 +1155,8 @@ static void quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfi
static void concurrent_rw_test(long isoftlimit, long bsoftlimit,
long user_postfix)
{
- int ret, fd, o_uid, j;
- long i, file_index, writen_size = 0;
+ int ret, fd, o_uid;
+ long i, writen_size = 0;
struct if_dqblk s_dq, d_dq;
char username[USERNAME_SZ];
char *write_buf;
@@ -1170,7 +1166,7 @@ static void concurrent_rw_test(long isoftlimit, long bsoftlimit,
if (!rank) {
- snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
+ snprintf(username, USERNAME_SZ, "quota-user-rank%d-%ld", rank,
user_postfix);
add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
@@ -1184,7 +1180,7 @@ static void concurrent_rw_test(long isoftlimit, long bsoftlimit,
setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
} else
- snprintf(username, USERNAME_SZ, "quota-user-rank0-%d",
+ snprintf(username, USERNAME_SZ, "quota-user-rank0-%ld",
user_postfix);
if (!rank) {
o_uid = getuid();
@@ -1253,10 +1249,7 @@ static void concurrent_rw_test(long isoftlimit, long bsoftlimit,
static void run_tests(void)
{
- int ret;
int i;
- int fd;
- int o_uid, o_gid;
struct if_dqblk s_dq, d_dq;
char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
@@ -1349,7 +1342,6 @@ static void run_tests(void)
static void setup(int argc, char *argv[])
{
- unsigned long i;
int ret;
int o_umask;
diff --git a/programs/reserve_space/reserve_space.c b/programs/reserve_space/reserve_space.c
index 9e91b09..1bffd9e 100644
--- a/programs/reserve_space/reserve_space.c
+++ b/programs/reserve_space/reserve_space.c
@@ -45,8 +45,8 @@ usage:
printf("File: %s\n", filename);
printf("cmd = %s\n", argv[1]);
printf("l_whence = %d\n", sr.l_whence);
- printf("l_start = %lld\n", sr.l_start);
- printf("l_len = %lld\n", sr.l_len);
+ printf("l_start = %lld\n", (long long int) sr.l_start);
+ printf("l_len = %lld\n", (long long int) sr.l_len);
fd = open(filename, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
if (fd == -1) {
diff --git a/programs/truncate/verify_truncate.c b/programs/truncate/verify_truncate.c
index 175305f..37d4236 100644
--- a/programs/truncate/verify_truncate.c
+++ b/programs/truncate/verify_truncate.c
@@ -222,7 +222,7 @@ int file_truncate(char *file_name, unsigned long long new_i_size)
int verify_truncate(char *file_name)
{
- int fd, ret = 0, o_ret;
+ int fd, ret = 0;
int open_ro_flags = O_RDONLY;
long i;
@@ -261,8 +261,8 @@ int verify_truncate(char *file_name)
}
if (memcmp(buf, pattern, clustersize)) {
- fprintf(stderr, "#%d cluster corrupted on %s.\n",
- file_name);
+ fprintf(stderr, "#%ld cluster corrupted on %s.\n",
+ i, file_name);
ret = -1;
goto out;
}
diff --git a/programs/xattr_tests/xattr-test-utils.c b/programs/xattr_tests/xattr-test-utils.c
index 503849a..8cdb537 100644
--- a/programs/xattr_tests/xattr-test-utils.c
+++ b/programs/xattr_tests/xattr-test-utils.c
@@ -21,6 +21,7 @@
*/
#include "xattr-test.h"
+#include <time.h>
extern char filename[MAX_FILENAME_SZ + 1];
extern unsigned long xattr_nums;
@@ -107,7 +108,7 @@ void xattr_name_generator(unsigned long xattr_no,
}
xattr_name[xattr_name_rsz - 6] = 0;
- snprintf(postfix, 7, "%06d", xattr_no);
+ snprintf(postfix, 7, "%06lu", xattr_no);
strcat(xattr_name, postfix);
strcpy(xattr_name_list_set[xattr_no], xattr_name);
}
@@ -193,7 +194,7 @@ int is_namelist_member(unsigned long nu, char *name, char **name_list)
int read_ea(enum FILE_TYPE ft, int fd)
{
- int ret;
+ int ret = 0;
switch (ft) {
case NORMAL:
@@ -237,7 +238,7 @@ int read_ea(enum FILE_TYPE ft, int fd)
int add_or_update_ea(enum FILE_TYPE ft, int fd, int ea_flags,
const char *prt_str)
{
- int ret;
+ int ret = 0;
switch (ft) {
case NORMAL:
@@ -246,9 +247,10 @@ int add_or_update_ea(enum FILE_TYPE ft, int fd, int ea_flags,
if (ret < 0) {
ret = errno;
fprintf(stderr, "Failed at fsetxattr(%s,errno:%d,%s) "
- "on %s:xattr_name=%s,xattr_value_sz=%d,"
+ "on %s:xattr_name=%s,xattr_value_sz=%llu,"
"xattr_value=%s\n", prt_str, ret, strerror(ret),
- filename, xattr_name, strlen(xattr_value) + 1,
+ filename, xattr_name,
+ (unsigned long long) strlen(xattr_value) + 1,
xattr_value);
ret = -1;
}
@@ -259,9 +261,10 @@ int add_or_update_ea(enum FILE_TYPE ft, int fd, int ea_flags,
if (ret < 0) {
ret = errno;
fprintf(stderr, "Failed at lsetxattr(%s,errno:%d,%s) "
- "on %s:xattr_name=%s,xattr_value_sz=%d,"
+ "on %s:xattr_name=%s,xattr_value_sz=%llu,"
"xattr_value=%s\n", prt_str, ret, strerror(ret),
- filename, xattr_name, strlen(xattr_value) + 1,
+ filename, xattr_name,
+ (unsigned long long)strlen(xattr_value) + 1,
xattr_value);
ret = -1;
}
@@ -272,9 +275,10 @@ int add_or_update_ea(enum FILE_TYPE ft, int fd, int ea_flags,
if (ret < 0) {
ret = errno;
fprintf(stderr, "Failed at setxattr(%s,errno:%d,%s) "
- "on %s:xattr_name=%s,xattr_value_sz=%d,"
+ "on %s:xattr_name=%s,xattr_value_sz=%llu,"
"xattr_value=%s\n", prt_str, ret, strerror(ret),
- filename, xattr_name, strlen(xattr_value) + 1,
+ filename, xattr_name,
+ (unsigned long long)strlen(xattr_value) + 1,
xattr_value);
ret = -1;
}
@@ -288,7 +292,7 @@ int add_or_update_ea(enum FILE_TYPE ft, int fd, int ea_flags,
int remove_ea(enum FILE_TYPE ft, int fd)
{
- int ret;
+ int ret = 0;
switch (ft) {
case NORMAL:
@@ -305,7 +309,7 @@ int remove_ea(enum FILE_TYPE ft, int fd)
ret = lremovexattr(filename, xattr_name);
if (ret < 0) {
ret = errno;
- fprintf(stderr, "Failed at lremovexattr(errno:%d,%d) "
+ fprintf(stderr, "Failed at lremovexattr(errno:%d,%s) "
"on %s:xattr_name=%s\n", ret, strerror(ret),
filename, xattr_name);
ret = -1;
@@ -348,9 +352,9 @@ void xattr_value_constructor(int xattr_entry_no)
strlen(value_postfix_magic) -
strlen(xattr_name) - 5);
- snprintf(value_sz, 6, "%05d", strlen(value_prefix_magic) +
+ snprintf(value_sz, 6, "%05d", (int)(strlen(value_prefix_magic) +
strlen(xattr_name) + strlen(xattr_value) + 5 +
- strlen(value_postfix_magic));
+ strlen(value_postfix_magic)));
strcpy(xattr_value_get, value_prefix_magic);
strcat(xattr_value_get, xattr_name);
diff --git a/programs/xattr_tests/xattr-test.c b/programs/xattr_tests/xattr-test.c
index 2e58ee2..90c0ae3 100755
--- a/programs/xattr_tests/xattr-test.c
+++ b/programs/xattr_tests/xattr-test.c
@@ -311,7 +311,7 @@ static void sigchld_handler()
static void kill_all_children()
{
int i;
- int process_nums;
+ int process_nums = 0;
if (do_multi_process_test == 1)
process_nums = child_nums;
@@ -342,7 +342,7 @@ static void sigterm_handler()
static void atexit_hook(void)
{
int i;
- int process_nums;
+ int process_nums = 0;
if (do_multi_process_test == 1)
process_nums = child_nums;
@@ -357,9 +357,8 @@ static void atexit_hook(void)
static void one_round_run(enum FILE_TYPE ft, int round_no)
{
- int fd, ret, status;
- DIR *dp;
- pid_t pid, ppid;
+ int fd = 0, ret, status;
+ pid_t pid;
unsigned long j;
int i, k;
char *write_buf = NULL;
@@ -611,7 +610,7 @@ static void one_round_run(enum FILE_TYPE ft, int round_no)
return;
}
/* Do normal update/add test*/
- printf("Test %d: Doing normal %d EAs adding and updating on file %s.\n",
+ printf("Test %d: Doing normal %lu EAs adding and updating on file %s.\n",
testno, xattr_nums, filename);
fflush(stdout);
@@ -671,7 +670,7 @@ static void one_round_run(enum FILE_TYPE ft, int round_no)
/*Here we do random_size update and check*/
if (!do_random_test)
goto list_test;
- printf("Test %d: Doing randomsize updating for %d EAs on file %s.\n",
+ printf("Test %d: Doing randomsize updating for %lu EAs on file %s.\n",
testno, xattr_nums, filename);
unsigned long update_iter;
--
2.1.4
More information about the Ocfs2-users
mailing list