2012-05-29 05:19:22

by Andreas Dilger

[permalink] [raw]
Subject: [PATCH 1/2] e2fsck,blkid,quota: quiet gcc -Wall build warnings

Quiet a number of minor, but mostly valid, compiler warnings.

For uninitialized variables, these could be fixed in a number
of different ways, but I chose mostly to leave them uninitialized
and fix the codepaths that result in this warning, to avoid hiding
potential errors in the future that incorrectly use this value.

A number of other miscellaneous compiler warnings were also fixed
in libquota, such as incorrect format strings.

Signed-off-by: Andreas Dilger <[email protected]>
---
e2fsck/message.c | 13 +++++++------
e2fsck/sigcatcher.c | 10 +++++++---
e2fsck/unix.c | 3 ++-
e2fsck/util.c | 1 -
lib/blkid/probe.c | 4 ++--
lib/blkid/probe.h | 2 +-
lib/ext2fs/dblist.c | 5 ++---
lib/ext2fs/qcow2.c | 2 +-
lib/ext2fs/rw_bitmaps.c | 1 -
lib/quota/common.h | 4 ++--
lib/quota/mkquota.c | 35 +++++++++++++++++++----------------
lib/quota/quotaio.c | 15 ++++++---------
lib/quota/quotaio_tree.c | 6 +++---
lib/quota/quotaio_v2.c | 5 ++---
resize/resize2fs.c | 16 ++++++++++------
15 files changed, 64 insertions(+), 58 deletions(-)

diff --git a/e2fsck/message.c b/e2fsck/message.c
index 980dc4b..0812a65 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -205,14 +205,15 @@ static void print_pathname(FILE *f, ext2_filsys fs, ext2_ino_t dir,
return;
}

- if (fs)
+ if (fs) {
retval = ext2fs_get_pathname(fs, dir, ino, &path);
- if (!fs || retval)
- fputs("???", f);
- else {
- safe_print(f, path, -1);
- ext2fs_free_mem(&path);
+ if (retval == 0) {
+ safe_print(f, path, -1);
+ ext2fs_free_mem(&path);
+ return;
+ }
}
+ fputs("???", f);
}

static void print_time(FILE *f, time_t t)
diff --git a/e2fsck/sigcatcher.c b/e2fsck/sigcatcher.c
index 10b9328..f18a105 100644
--- a/e2fsck/sigcatcher.c
+++ b/e2fsck/sigcatcher.c
@@ -251,6 +251,7 @@ static struct str_table sigbus_code_table[] = {
END_TABLE
};

+#if 0
static struct str_table sigstrap_code_table[] = {
#ifdef TRAP_BRKPT
DEFINE_ENTRY(TRAP_BRKPT)
@@ -260,6 +261,7 @@ static struct str_table sigstrap_code_table[] = {
#endif
END_TABLE
};
+#endif

static struct str_table sigcld_code_table[] = {
#ifdef CLD_EXITED
@@ -283,6 +285,7 @@ static struct str_table sigcld_code_table[] = {
END_TABLE
};

+#if 0
static struct str_table sigpoll_code_table[] = {
#ifdef POLL_IN
DEFINE_ENTRY(POLL_IN)
@@ -304,6 +307,7 @@ static struct str_table sigpoll_code_table[] = {
#endif
END_TABLE
};
+#endif

static const char *lookup_table(int num, struct str_table *table)
{
@@ -378,7 +382,7 @@ static void die_signal_handler(int signum, siginfo_t *siginfo, void *context)
void sigcatcher_setup(void)
{
struct sigaction sa;
-
+
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_sigaction = die_signal_handler;
sa.sa_flags = SA_SIGINFO;
@@ -387,7 +391,7 @@ void sigcatcher_setup(void)
sigaction(SIGILL, &sa, 0);
sigaction(SIGBUS, &sa, 0);
sigaction(SIGSEGV, &sa, 0);
-}
+}


#ifdef DEBUG
@@ -403,7 +407,7 @@ int main(int argc, char** argv)
{
struct sigaction sa;
char *p = 0;
- int i, c;
+ int i, c;
volatile x=0;

memset(&sa, 0, sizeof(struct sigaction));
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 6161e46..7528ee9 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1140,7 +1140,7 @@ int main (int argc, char *argv[])
int old_bitmaps;
__u32 features[3];
char *cp;
- int qtype; /* quota type */
+ int qtype = -2; /* quota type, will be reset before actual use */

clear_problem_context(&pctx);
sigcatcher_setup();
@@ -1621,6 +1621,7 @@ no_journal:

if (ctx->qctx) {
int i, needs_writeout;
+
for (i = 0; i < MAXQUOTAS; i++) {
if (qtype != -1 && qtype != i)
continue;
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 7c4caab..f3ba645 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -795,7 +795,6 @@ void e2fsck_set_bitmap_type(ext2_filsys fs, unsigned int default_type,
const char *profile_name, unsigned int *old_type)
{
unsigned type;
- errcode_t retval;

if (old_type)
*old_type = fs->default_bitmap_type;
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 6970b12..2e3557e 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -1171,7 +1171,7 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),
(memcmp(hfs->embed_sig, "HX", 2) == 0))
return 1; /* Not hfs, but an embedded HFS+ */

- uuid = blkid_le64(*((unsigned long long *) hfs->finder_info.id));
+ uuid = blkid_le64(hfs->finder_info.id);
if (uuid) {
sprintf(uuid_str, "%016llX", uuid);
blkid_set_tag(probe->dev, "UUID", uuid_str, 0);
@@ -1235,7 +1235,7 @@ static int probe_hfsplus(struct blkid_probe *probe,
(memcmp(hfsplus->signature, "HX", 2) != 0))
return 1;

- uuid = blkid_le64(*((unsigned long long *) hfsplus->finder_info.id));
+ uuid = blkid_le64(hfsplus->finder_info.id);
if (uuid) {
sprintf(uuid_str, "%016llX", uuid);
blkid_set_tag(probe->dev, "UUID", uuid_str, 0);
diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h
index 37e80ef..d160e8b 100644
--- a/lib/blkid/probe.h
+++ b/lib/blkid/probe.h
@@ -502,7 +502,7 @@ struct hfs_finder_info {
__u32 os9_folder;
__u32 reserved;
__u32 osx_folder;
- __u8 id[8];
+ __u64 id;
} __attribute__((packed));

struct hfs_mdb {
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index ca1446b..4026682 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -72,10 +72,9 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
(fs->dblist->magic == EXT2_ET_MAGIC_DBLIST))
return 0;

- retval = ext2fs_get_mem(sizeof(struct ext2_struct_dblist), &dblist);
+ retval = ext2fs_get_memzero(sizeof(struct ext2_struct_dblist), &dblist);
if (retval)
- goto cleanup;
- memset(dblist, 0, sizeof(struct ext2_struct_dblist));
+ return retval;

dblist->magic = EXT2_ET_MAGIC_DBLIST;
dblist->fs = fs;
diff --git a/lib/ext2fs/qcow2.c b/lib/ext2fs/qcow2.c
index b0a0278..7fb983d 100644
--- a/lib/ext2fs/qcow2.c
+++ b/lib/ext2fs/qcow2.c
@@ -176,7 +176,7 @@ int qcow2_write_raw_image(int qcow2_fd, int raw_fd,

ret = ext2fs_get_memzero(img.cluster_size, &l2_table);
if (ret)
- goto out;
+ return ret;

ret = ext2fs_get_memzero(1 << img.cluster_bits, &copy_buf);
if (ret)
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 53f6ec4..3f3ed65 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -154,7 +154,6 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
int csum_flag = 0;
- int do_image = fs->flags & EXT2_FLAG_IMAGE_FILE;
unsigned int cnt;
blk64_t blk;
blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
diff --git a/lib/quota/common.h b/lib/quota/common.h
index b5e8331..747ef5d 100644
--- a/lib/quota/common.h
+++ b/lib/quota/common.h
@@ -15,12 +15,12 @@

#define log_err(format, ...) fprintf(stderr, \
"[ERROR] %s:%d:%s:: " format "\n", \
- __FILE__, __LINE__, __func__, __VA_ARGS__)
+ __FILE__, __LINE__, __func__, ## __VA_ARGS__)

#ifdef DEBUG_QUOTA
# define log_debug(format, ...) fprintf(stderr, \
"[DEBUG] %s:%d:%s:: " format "\n", \
- __FILE__, __LINE__, __func__, __VA_ARGS__)
+ __FILE__, __LINE__, __func__, ## __VA_ARGS__)
#else
# define log_debug(format, ...)
#endif
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index 973c35e..6bebe68 100644
--- a/lib/quota/mkquota.c
+++ b/lib/quota/mkquota.c
@@ -26,6 +26,7 @@
#define UINT_TO_VOIDPTR(val) ((void *)(intptr_t)(val))
#define VOIDPTR_TO_UINT(ptr) ((unsigned int)(intptr_t)(ptr))

+#if 0
static void print_inode(struct ext2_inode *inode)
{
if (!inode)
@@ -45,6 +46,7 @@ static void print_inode(struct ext2_inode *inode)

return;
}
+#endif

/*
* Returns 0 if not able to find the quota file, otherwise returns its
@@ -131,8 +133,8 @@ errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)
fs = qctx->fs;
retval = ext2fs_get_mem(sizeof(struct quota_handle), &h);
if (retval) {
- log_err("Unable to allocate quota handle", "");
- goto out;
+ log_err("Unable to allocate quota handle");
+ return retval;
}

ext2fs_read_bitmaps(fs);
@@ -147,7 +149,7 @@ errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)

retval = quota_file_create(h, fs, i, fmt);
if (retval < 0) {
- log_err("Cannot initialize io on quotafile", "");
+ log_err("Cannot initialize io on quotafile");
continue;
}

@@ -170,7 +172,7 @@ errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)
}

ext2fs_write_bitmaps(fs);
-out:
+
if (h)
ext2fs_free_mem(&h);
return retval;
@@ -215,19 +217,18 @@ errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype)
dict_t *dict;
quota_ctx_t ctx;

- err = ext2fs_get_mem(sizeof(struct quota_ctx), &ctx);
+ err = ext2fs_get_memzero(sizeof(struct quota_ctx), &ctx);
if (err) {
- log_err("Failed to allocate quota context", "");
+ log_err("Failed to allocate quota context");
return err;
}

- memset(ctx, 0, sizeof(struct quota_ctx));
for (i = 0; i < MAXQUOTAS; i++) {
if ((qtype != -1) && (i != qtype))
continue;
err = ext2fs_get_mem(sizeof(dict_t), &dict);
if (err) {
- log_err("Failed to allocate dictionary", "");
+ log_err("Failed to allocate dictionary");
return err;
}
ctx->quota_dict[i] = dict;
@@ -272,7 +273,7 @@ static struct dquot *get_dq(dict_t *dict, __u32 key)
dq = dnode_get(n);
else {
if (ext2fs_get_mem(sizeof(struct dquot), &dq)) {
- log_err("Unable to allocate dquot", "");
+ log_err("Unable to allocate dquot");
return NULL;
}
memset(dq, 0, sizeof(struct dquot));
@@ -420,9 +421,11 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data)
dq->dq_dqb.dqb_curinodes != dquot->dq_dqb.dqb_curinodes) {
scan_data->usage_is_inconsistent = 1;
log_err("Usage inconsistent for ID %d: (%llu, %llu) != "
- "(%llu, %llu)", dq->dq_id, dq->dq_dqb.dqb_curspace,
- dq->dq_dqb.dqb_curinodes, dquot->dq_dqb.dqb_curspace,
- dquot->dq_dqb.dqb_curinodes);
+ "(%llu, %llu)", dq->dq_id,
+ (unsigned long long)dq->dq_dqb.dqb_curspace,
+ (unsigned long long)dq->dq_dqb.dqb_curinodes,
+ (unsigned long long)dquot->dq_dqb.dqb_curspace,
+ (unsigned long long)dquot->dq_dqb.dqb_curinodes);
}

if (scan_data->update_limits) {
@@ -486,13 +489,13 @@ errcode_t quota_update_inode(quota_ctx_t qctx, ext2_ino_t qf_ino, int type)

err = ext2fs_get_mem(sizeof(struct quota_handle), &qh);
if (err) {
- log_err("Unable to allocate quota handle", "");
+ log_err("Unable to allocate quota handle");
return err;
}

err = quota_file_open(qh, qctx->fs, qf_ino, type, -1, EXT2_FILE_WRITE);
if (err) {
- log_err("Open quota file failed", "");
+ log_err("Open quota file failed");
goto out;
}

@@ -532,7 +535,7 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
fs->super->s_grp_quota_inum;
err = quota_file_open(&qh, fs, qf_ino, qtype, -1, 0);
if (err) {
- log_err("Open quota file failed", "");
+ log_err("Open quota file failed");
goto out;
}

@@ -542,7 +545,7 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
scan_data.usage_is_inconsistent = 0;
err = qh.qh_ops->scan_dquots(&qh, scan_dquots_callback, &scan_data);
if (err) {
- log_err("Error scanning dquots", "");
+ log_err("Error scanning dquots");
goto out;
}
*usage_inconsistent = scan_data.usage_is_inconsistent;
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index 6e917f0..3b3bc0f 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -66,7 +66,6 @@ const char *quota_get_qf_name(int type, int fmt, char *buf)
const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
char *path_buf, size_t path_buf_size)
{
- struct stat qf_stat;
char qf_name[QUOTA_NAME_LEN];

if (!mntpt || !path_buf || !path_buf_size)
@@ -126,7 +125,6 @@ static int compute_num_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
int ref_offset EXT2FS_ATTR((unused)),
void *private)
{
- blk64_t block;
blk64_t *num_blocks = private;

*num_blocks += 1;
@@ -137,7 +135,6 @@ errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino)
{
struct ext2_inode inode;
errcode_t err;
- int i;

if ((err = ext2fs_read_inode(fs, ino, &inode)))
return err;
@@ -250,13 +247,13 @@ errcode_t quota_file_open(struct quota_handle *h, ext2_filsys fs,

if (h->qh_ops->check_file &&
(h->qh_ops->check_file(h, type, fmt) == 0)) {
- log_err("qh_ops->check_file failed", "");
+ log_err("qh_ops->check_file failed");
ext2fs_file_close(e2_file);
return -1;
}

if (h->qh_ops->init_io && (h->qh_ops->init_io(h) < 0)) {
- log_err("qh_ops->init_io failed", "");
+ log_err("qh_ops->init_io failed");
ext2fs_file_close(e2_file);
return -1;
}
@@ -271,7 +268,7 @@ static errcode_t quota_inode_init_new(ext2_filsys fs, ext2_ino_t ino)

err = ext2fs_read_inode(fs, ino, &inode);
if (err) {
- log_err("ex2fs_read_inode failed", "");
+ log_err("ex2fs_read_inode failed");
return err;
}

@@ -323,7 +320,7 @@ errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs, int type, in

err = quota_inode_init_new(fs, qf_inum);
if (err) {
- log_err("init_new_quota_inode failed", "");
+ log_err("init_new_quota_inode failed");
goto out_err;
}
h->qh_qf.ino = qf_inum;
@@ -346,7 +343,7 @@ errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs, int type, in
h->qh_ops = &quotafile_ops_2;

if (h->qh_ops->new_io && (h->qh_ops->new_io(h) < 0)) {
- log_err("qh_ops->new_io failed", "");
+ log_err("qh_ops->new_io failed");
goto out_err1;
}

@@ -393,7 +390,7 @@ struct dquot *get_empty_dquot(void)
struct dquot *dquot;

if (ext2fs_get_memzero(sizeof(struct dquot), &dquot)) {
- log_err("Failed to allocate dquot", "");
+ log_err("Failed to allocate dquot");
return NULL;
}

diff --git a/lib/quota/quotaio_tree.c b/lib/quota/quotaio_tree.c
index 9080e77..80e4850 100644
--- a/lib/quota/quotaio_tree.c
+++ b/lib/quota/quotaio_tree.c
@@ -24,7 +24,7 @@ static inline dqbuf_t getdqbuf(void)
{
dqbuf_t buf;
if (ext2fs_get_memzero(QT_BLKSIZE, &buf)) {
- log_err("Failed to allocate dqbuf", "");
+ log_err("Failed to allocate dqbuf");
return NULL;
}

@@ -101,7 +101,7 @@ static int get_free_dqblk(struct quota_handle *h)
if (write_blk(h, info->dqi_blocks, buf) < 0) {
freedqbuf(buf);
log_err("Cannot allocate new quota block "
- "(out of disk space).", "");
+ "(out of disk space).");
return -ENOSPC;
}
blk = info->dqi_blocks++;
@@ -231,7 +231,7 @@ static uint find_free_dqentry(struct quota_handle *h, struct dquot *dquot,

if (i == qtree_dqstr_in_blk(info))
log_err("find_free_dqentry(): Data block full but it "
- "shouldn't.", "");
+ "shouldn't.");

write_blk(h, blk, buf);
dquot->dq_dqb.u.v2_mdqb.dqb_off =
diff --git a/lib/quota/quotaio_v2.c b/lib/quota/quotaio_v2.c
index e658706..b90bb6e 100644
--- a/lib/quota/quotaio_v2.c
+++ b/lib/quota/quotaio_v2.c
@@ -198,8 +198,7 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt)

if (ext2fs_le32_to_cpu(dqh.dqh_magic) != file_magics[type]) {
if (ext2fs_be32_to_cpu(dqh.dqh_magic) == file_magics[type])
- log_err("Your quota file is stored in wrong "
- "endianity.", "");
+ log_err("The quota file is stored in wrong endianity.");
return 0;
}
if (ext2fs_le32_to_cpu(dqh.dqh_version) > known_versions[type])
@@ -320,6 +319,6 @@ static int v2_scan_dquots(struct quota_handle *h,
*/
static int v2_report(struct quota_handle *h, int verbose)
{
- log_err("Not Implemented.", "");
+ log_err("Not Implemented.");
return -1;
}
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index dc2805d..4a78dd2 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1708,24 +1708,27 @@ static errcode_t fix_resize_inode(ext2_filsys fs)
{
struct ext2_inode inode;
errcode_t retval;
- char * block_buf;
+ char *block_buf;

if (!(fs->super->s_feature_compat &
EXT2_FEATURE_COMPAT_RESIZE_INODE))
return 0;

retval = ext2fs_get_mem(fs->blocksize, &block_buf);
- if (retval) goto errout;
+ if (retval)
+ return retval;

retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
- if (retval) goto errout;
+ if (retval)
+ goto errout;

ext2fs_iblk_set(fs, &inode, 1);

retval = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode);
- if (retval) goto errout;
+ if (retval)
+ goto errout;

- if (!inode.i_block[EXT2_DIND_BLOCK]) {
+ if (inode.i_block[EXT2_DIND_BLOCK] == 0) {
/*
* Avoid zeroing out block #0; that's rude. This
* should never happen anyway since the filesystem
@@ -1740,7 +1743,8 @@ static errcode_t fix_resize_inode(ext2_filsys fs)

retval = io_channel_write_blk64(fs->io, inode.i_block[EXT2_DIND_BLOCK],
1, block_buf);
- if (retval) goto errout;
+ if (retval)
+ goto errout;

retval = ext2fs_create_resize_inode(fs);
if (retval)
--
1.7.3.4



2012-05-29 05:19:24

by Andreas Dilger

[permalink] [raw]
Subject: [PATCH 2/2] tests: quiet "make check" gcc -Wall warnings

Quiet a number of GCC compiler warnings about unused variables,
use of uninitialized variables, and function return without value
hit when running "make check".

In a number of places, the output format from "make check" is
incorrectly interpreted as compiler warning output (triggered by
the presence of colons and parenthesis in the output). Convert
these lines to similar output that does not trigger false build
warnings.

In the case of the tst_uuid.c program, the "ctime()" output was
difficult to change, but in fact it is better to actually compare
the time-based UUID against wallclock time instead of just printing
the formatted time as a string, so this test is improved.

Signed-off-by: Andreas Dilger <[email protected]>
---
e2fsck/problem.c | 2 +-
e2fsck/region.c | 2 +-
lib/ext2fs/crc32c.c | 5 +++--
lib/ext2fs/csum.c | 9 +++------
lib/ext2fs/inline.c | 2 +-
lib/ext2fs/tst_bitmaps.c | 13 ++++++-------
lib/uuid/tst_uuid.c | 28 +++++++++++++++++++++-------
7 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 0948bdb..ca3fa01 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1816,7 +1816,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
return 0;
}
if (!(ptr->flags & PR_CONFIG)) {
- char key[9], *new_desc;
+ char key[9], *new_desc = NULL;

sprintf(key, "0x%06x", code);

diff --git a/e2fsck/region.c b/e2fsck/region.c
index e9abb56..4b669f0 100644
--- a/e2fsck/region.c
+++ b/e2fsck/region.c
@@ -171,7 +171,7 @@ void region_print(region_t region, FILE *f)

int main(int argc, char **argv)
{
- region_t r;
+ region_t r = NULL;
int pc = 0, ret;
region_addr_t start, end;

diff --git a/lib/ext2fs/crc32c.c b/lib/ext2fs/crc32c.c
index da2c60b..d8034c4 100644
--- a/lib/ext2fs/crc32c.c
+++ b/lib/ext2fs/crc32c.c
@@ -1113,15 +1113,16 @@ static int test_crc32c(void)

while (t->length) {
uint32_t be, le;
+
le = ext2fs_crc32c_le(t->crc, test_buf + t->start, t->length);
be = ext2fs_crc32c_be(t->crc, test_buf + t->start, t->length);
if (le != t->crc_le) {
- printf("Test %d LE fails, %x != %x\n",
+ printf("Test %ld LE fails, %x != %x\n",
(t - test), le, t->crc_le);
failures++;
}
if (be != t->crc_be) {
- printf("Test %d BE fails, %x != %x\n",
+ printf("Test %ld BE fails, %x != %x\n",
(t - test), be, t->crc_be);
failures++;
}
diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c
index 9fa3f24..4788a6c 100644
--- a/lib/ext2fs/csum.c
+++ b/lib/ext2fs/csum.c
@@ -39,10 +39,6 @@ __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
size = fs->super->s_desc_size;
if (size < EXT2_MIN_DESC_SIZE)
size = EXT2_MIN_DESC_SIZE;
- if (size > sizeof(struct ext4_group_desc)) {
- printf("%s: illegal s_desc_size(%zd)\n", __func__, size);
- size = sizeof(struct ext4_group_desc);
- }

desc = ext2fs_group_desc(fs, fs->group_desc, group);

@@ -166,7 +162,7 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
{
__u16 crc1, crc2, crc3;
dgrp_t swabgroup;
- struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc, group);
+ struct ext2_group_desc *desc;
size_t size;
struct ext2_super_block *sb = fs->super;
int offset = offsetof(struct ext2_group_desc, bg_checksum);
@@ -174,6 +170,7 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
struct ext4_group_desc swabdesc;
#endif

+ desc = ext2fs_group_desc(fs, fs->group_desc, group);
size = fs->super->s_desc_size;
if (size < EXT2_MIN_DESC_SIZE)
size = EXT2_MIN_DESC_SIZE;
@@ -198,7 +195,7 @@ void print_csum(const char *msg, ext2_filsys fs, dgrp_t group)
if (offset < size)
crc3 = ext2fs_crc16(crc3, (char *)desc + offset, size - offset);

- printf("%s: UUID %s(%04x), grp %u(%04x): %04x=%04x\n",
+ printf("%s UUID %s=%04x, grp %u=%04x: %04x=%04x\n",
msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2, crc3,
ext2fs_group_desc_csum(fs, group));
}
diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c
index eef3dda..05da1f7 100644
--- a/lib/ext2fs/inline.c
+++ b/lib/ext2fs/inline.c
@@ -99,7 +99,7 @@ static errcode_t test_memalign(unsigned long align)
if (!retval && !isaligned(ptr, align))
retval = EINVAL;
free(ptr);
- printf("tst_memliagn(%lu): %s\n", align,
+ printf("tst_memalign(%lu) is %s\n", align,
retval ? error_message(retval) : "OK");
return retval;
}
diff --git a/lib/ext2fs/tst_bitmaps.c b/lib/ext2fs/tst_bitmaps.c
index 22346a2..b49111b 100644
--- a/lib/ext2fs/tst_bitmaps.c
+++ b/lib/ext2fs/tst_bitmaps.c
@@ -193,8 +193,7 @@ errout:

void setup_cmd(int argc, char **argv)
{
- errcode_t retval;
- int i, c, err;
+ int c, err;
unsigned int blocks = 128;
unsigned int inodes = 0;
unsigned int type = EXT2FS_BMAP64_BITARRAY;
@@ -372,7 +371,7 @@ void do_testb(int argc, char *argv[])
{
unsigned int block, num;
int err;
- int test_result, op_result;
+ int test_result;

if (check_fs_open(argv[0]))
return;
@@ -508,7 +507,7 @@ void do_testi(int argc, char *argv[])
{
unsigned int inode;
int err;
- int test_result, op_result;
+ int test_result;

if (check_fs_open(argv[0]))
return;
@@ -588,13 +587,13 @@ int main(int argc, char **argv)
blocks = parse_ulong(optarg, argv[0],
"number of blocks", &err);
if (err)
- return;
+ return err;
break;
case 'i':
inodes = parse_ulong(optarg, argv[0],
"number of blocks", &err);
if (err)
- return;
+ return err;
break;
case 'l': /* Legacy bitmaps */
flags = 0;
@@ -603,7 +602,7 @@ int main(int argc, char **argv)
type = parse_ulong(optarg, argv[0],
"bitmap backend type", &err);
if (err)
- return;
+ return err;
break;
case 'R':
request = optarg;
diff --git a/lib/uuid/tst_uuid.c b/lib/uuid/tst_uuid.c
index 5884ad9..2216970 100644
--- a/lib/uuid/tst_uuid.c
+++ b/lib/uuid/tst_uuid.c
@@ -74,7 +74,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
uuid_t buf, tst;
char str[100];
struct timeval tv;
- time_t time_reg;
+ time_t time_reg, time_gen;
unsigned char *cp;
int i;
int failed = 0;
@@ -104,7 +104,8 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = uuid_type(buf);
+ variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -117,6 +118,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
}
printf("\n");

+ time_gen = time(0);
uuid_generate_time(buf);
uuid_unparse(buf, str);
printf("UUID string = %s\n", str);
@@ -125,7 +127,8 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = uuid_type(buf);
+ variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -136,15 +139,25 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
"1 (time-based type)!\\n");
failed++;
}
+
tv.tv_sec = 0;
tv.tv_usec = 0;
time_reg = uuid_time(buf, &tv);
- printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
- ctime(&time_reg));
+ printf("UUID generated at %lu reports %lu (%ld.%ld)\n",
+ time_gen, time_reg, tv.tv_sec, tv.tv_usec);
+ /* allow 1s margin in case of rollover between sampling
+ * the current time and when the UUID is generated. */
+ if (time_reg > time_gen + 1) {
+ printf("UUID time comparison failed!\n");
+ failed++;
+ } else {
+ printf("UUID time comparison succeeded.\n");
+ }
+
uuid_parse(str, tst);
- if (!uuid_compare(buf, tst))
+ if (!uuid_compare(buf, tst)) {
printf("UUID parse and compare succeeded.\n");
- else {
+ } else {
printf("UUID parse and compare failed!\n");
failed++;
}
@@ -162,6 +175,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
printf("UUID copy and compare failed!\n");
failed++;
}
+
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1);
failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1);
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0);
--
1.7.3.4