[gfs2-utils] branch andyp-sparse deleted (was 6206a0b7)
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a change to branch andyp-sparse
in repository gfs2-utils.
was 6206a0b7 fsck.gfs2: Fix remaining endianness sparse warnings
This change permanently discards the following revisions:
discard 6206a0b7 fsck.gfs2: Fix remaining endianness sparse warnings
discard e2d50e60 gfs2_edit: Fix remaining endianness sparse warnings
discard fc23b1f6 gfs2_convert: Fix the remaining sparse warnings
discard 58f33f9c libgfs2: Fix the remaining sparse warnings
discard d5e853c9 fsck.gfs2: Remove unused invalidate_fxns
discard e57ccf23 Fix sparse warnings about linkage
discard ad63b07a libgfs2: Remove gfs_jindex_in
discard 12a28255 libgfs2: Fix endianness tagging for gfs2_bit_search
discard 90d0e320 gfs2l: Sparse fixes
discard c4a50183 libgfs2: Broaden use of struct lgfs2_inum
discard 028e996c libgfs2: Don't parse/write de_cookie
discard 328230d1 libgfs2: Fix endianness conversions for superblock padding fields
discard 7f49fb53 libgfs2: Remove gfs2_meta_header_{in,out}
discard ff7332fd libgfs2: Endianness improvements for gfs2_leaf
discard fd1b3810 Remove some users of gfs2_leaf_in()
discard 259eab1d libgfs2: Endianness improvements for gfs2_inum and gfs2_dirent
discard d9e8ae78 gfs2_edit: Use native-endian types for dirent processing
discard 9feafd77 libgfs2: Remove some now-unused functions
discard 0489202a libgfs2: Remove sd_sb from struct gfs2_sbd
discard d8a351b1 libgfs2: Remove big-endian structs from struct rgrp_tree
discard e5bc9656 libgfs2: Remove i_di from struct gfs2_inode
discard 708154bf libgfs2: Remove gfs2_dinode_print()
discard 9402792a libgfs2: Add a cpu-endian log header struct
discard f061b55f gfs2_edit: Clean up display_gfs2()
discard 0ea32926 libgfs2: Fix endianness mismatches for struct gfs2_log_header
discard 99eeaec8 libgfs2: Don't use on-disk structs with cpu-endian data in __init_dinode
discard f1d10e69 gfs2_edit: Store big-endian data in the global dinode
discard 7b7515f7 gfs2_edit: Convert superblock printing to expect big-endian
discard 6de94a06 libgfs2: Convert gfs2_sb_print to expect big-endian data
discard 231938c4 Convert rgrp printing functions to expect big-endian data
discard c841138f libgfs2: Remove gfs2_quota_{in,out}
discard 411aa2e8 libgfs2: Convert gfs2_leaf_print to accept big-endian data
discard 018c2b6a libgfs2: Remove gfs2_ea_header_in
discard ac0aa85c libgfs2: Remove gfs2_statfs_change_{in,out}
discard 5fe42ca0 libgfs2: Remove gfs2_quota_change_{in,out}
discard 2b6ca657 libgfs2: Remove gfs2_log_descriptor_{in,out}
discard f42aeb72 libgfs2: Expect big-endian data when printing log descriptors
discard c10073cb libgfs2: Add a function for printing on-disk meta headers
discard 9ab2d40f libgfs2: Provide macros for printing on-disk fields
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 39/39: fsck.gfs2: Fix remaining endianness sparse
warnings
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit e84bce321352f8b3521bb3a1756a0887966b4120
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jun 14 17:58:44 2021 +0100
fsck.gfs2: Fix remaining endianness sparse warnings
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 2 +-
gfs2/fsck/afterpass1_common.h | 2 +-
gfs2/fsck/fs_recovery.c | 16 ++++------
gfs2/fsck/initialize.c | 72 ++++++++++++++++---------------------------
gfs2/fsck/lost_n_found.c | 2 +-
gfs2/fsck/metawalk.c | 35 +++++++++++----------
gfs2/fsck/metawalk.h | 8 ++---
gfs2/fsck/pass1.c | 6 ++--
gfs2/fsck/pass1b.c | 12 ++++----
gfs2/fsck/pass2.c | 19 ++++++------
gfs2/fsck/util.c | 4 +--
gfs2/fsck/util.h | 2 +-
gfs2/libgfs2/gfs1.c | 4 +--
gfs2/libgfs2/libgfs2.h | 2 +-
14 files changed, 82 insertions(+), 104 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 9b849316..6e5fbe0c 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -279,7 +279,7 @@ int delete_eattr_entry(struct gfs2_inode *ip, struct gfs2_buffer_head *leaf_bh,
return 0;
}
-int delete_eattr_extentry(struct gfs2_inode *ip, int i, uint64_t *ea_data_ptr,
+int delete_eattr_extentry(struct gfs2_inode *ip, int i, __be64 *ea_data_ptr,
struct gfs2_buffer_head *leaf_bh, uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
struct gfs2_ea_header *ea_hdr_prev, void *private)
diff --git a/gfs2/fsck/afterpass1_common.h b/gfs2/fsck/afterpass1_common.h
index e12ed96e..51cb2140 100644
--- a/gfs2/fsck/afterpass1_common.h
+++ b/gfs2/fsck/afterpass1_common.h
@@ -20,7 +20,7 @@ extern int delete_eattr_entry(struct gfs2_inode *ip,
struct gfs2_ea_header *ea_hdr_prev,
void *private);
extern int delete_eattr_extentry(struct gfs2_inode *ip, int i,
- uint64_t *ea_data_ptr,
+ __be64 *ea_data_ptr,
struct gfs2_buffer_head *leaf_bh,
uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index b62f7a65..12b8d704 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -138,7 +138,7 @@ static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
gfs2_replay_incr_blk(ip, &start);
for (; blks; gfs2_replay_incr_blk(ip, &start), blks--) {
- uint32_t check_magic;
+ struct gfs2_meta_header *mhp;
sd_found_metablocks++;
@@ -162,10 +162,8 @@ static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
}
memcpy(bh_ip->b_data, bh_log->b_data, sdp->sd_bsize);
- check_magic = ((struct gfs2_meta_header *)
- (bh_ip->b_data))->mh_magic;
- check_magic = be32_to_cpu(check_magic);
- if (check_magic != GFS2_MAGIC) {
+ mhp = (struct gfs2_meta_header *)bh_ip->b_data;
+ if (be32_to_cpu(mhp->mh_magic) != GFS2_MAGIC) {
log_err(_("Journal corruption detected at block #"
"%lld (0x%llx) for journal+0x%x.\n"),
(unsigned long long)blkno, (unsigned long long)blkno,
@@ -322,15 +320,13 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
offset &= ~(sizeof(__be64) - 1);
while (start != end) {
- uint32_t check_magic;
+ struct gfs2_meta_header *mhp;
error = gfs2_replay_read_block(ip, start, &bh);
if (error)
return error;
- check_magic = ((struct gfs2_meta_header *)
- (bh->b_data))->mh_magic;
- check_magic = be32_to_cpu(check_magic);
- if (check_magic != GFS2_MAGIC) {
+ mhp = (struct gfs2_meta_header *)bh->b_data;
+ if (be32_to_cpu(mhp->mh_magic) != GFS2_MAGIC) {
bmodified(bh);
brelse(bh);
return -EIO;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 4bc7eef6..9ba4bc89 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -788,7 +788,7 @@ static int fetch_rgrps(struct gfs2_sbd *sdp)
*/
static int init_system_inodes(struct gfs2_sbd *sdp)
{
- uint64_t inumbuf = 0;
+ __be64 inumbuf = 0;
char *buf;
int err;
@@ -1143,8 +1143,6 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
uint64_t blk, max_rg_size, rb_addr;
struct gfs2_buffer_head *bh, *rb_bh;
uint32_t bsize, bsize2;
- uint32_t chk;
- char *p;
int found_rg;
sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
@@ -1154,14 +1152,13 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
for (blk = startblock; blk < startblock + max_rg_size; blk++) {
bh = bread(sdp, blk);
found_rg = 0;
- for (bsize = 0; bsize < GFS2_DEFAULT_BSIZE;
- bsize += GFS2_BASIC_BLOCK) {
- p = bh->b_data + bsize;
- chk = ((struct gfs2_meta_header *)p)->mh_magic;
- if (be32_to_cpu(chk) != GFS2_MAGIC)
+ for (bsize = 0; bsize < GFS2_DEFAULT_BSIZE; bsize += GFS2_BASIC_BLOCK) {
+ struct gfs2_meta_header *mhp;
+
+ mhp = (struct gfs2_meta_header *)(bh->b_data + bsize);
+ if (be32_to_cpu(mhp->mh_magic) != GFS2_MAGIC)
continue;
- chk = ((struct gfs2_meta_header *)p)->mh_type;
- if (be32_to_cpu(chk) == GFS2_METATYPE_RG) {
+ if (be32_to_cpu(mhp->mh_type) == GFS2_METATYPE_RG) {
found_rg = 1;
break;
}
@@ -1382,23 +1379,6 @@ static int fill_super_block(struct gfs2_sbd *sdp)
return 0;
}
-static void gfs_log_header_out(struct gfs_log_header *head, char *buf)
-{
- struct gfs_log_header *str = (struct gfs_log_header *) buf;
-
- str->lh_header.mh_magic = cpu_to_be32(head->lh_header.mh_magic);
- str->lh_header.mh_type = cpu_to_be32(head->lh_header.mh_type);
- str->lh_header.mh_format = cpu_to_be32(head->lh_header.mh_format);
- str->lh_header.__pad0 = cpu_to_be32(head->lh_header.__pad0);
-
- str->lh_flags = cpu_to_be32(head->lh_flags);
- str->lh_pad = cpu_to_be32(head->lh_pad);
- str->lh_first = cpu_to_be64(head->lh_first);
- str->lh_sequence = cpu_to_be64(head->lh_sequence);
- str->lh_tail = cpu_to_be64(head->lh_tail);
- str->lh_last_dump = cpu_to_be64(head->lh_last_dump);
-}
-
/*
* reconstruct_single_journal - write a fresh GFS1 journal
* @sdp: superblock
@@ -1413,31 +1393,33 @@ static void gfs_log_header_out(struct gfs_log_header *head, char *buf)
static int reconstruct_single_journal(struct gfs2_sbd *sdp, int jnum,
uint32_t ji_nsegment)
{
- struct gfs_log_header lh;
- uint32_t seg, sequence;
+ uint64_t first = sdp->md.journal[jnum]->i_num.in_addr;
struct gfs2_buffer_head *bh;
+ uint64_t sequence;
srandom(time(NULL));
sequence = ji_nsegment / (RAND_MAX + 1.0) * random();
log_info(_("Clearing journal %d\n"), jnum);
- for (seg = 0; seg < ji_nsegment; seg++){
- memset(&lh, 0, sizeof(struct gfs_log_header));
-
- lh.lh_header.mh_magic = GFS2_MAGIC;
- lh.lh_header.mh_type = GFS2_METATYPE_LH;
- lh.lh_header.mh_format = GFS2_FORMAT_LH;
- lh.lh_header.__pad0 = 0x101674; /* mh_generation */
- lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
- lh.lh_first = sdp->md.journal[jnum]->i_num.in_addr + (seg * sdp->sd_seg_size);
- lh.lh_sequence = sequence;
-
- bh = bget(sdp, lh.lh_first * sdp->sd_bsize);
- memset(bh->b_data, 0, sdp->sd_bsize);
- gfs_log_header_out(&lh, bh->b_data);
- gfs_log_header_out(&lh, bh->b_data + GFS2_BASIC_BLOCK -
- sizeof(struct gfs_log_header));
+ for (int seg = 0; seg < ji_nsegment; seg++, first += sdp->sd_seg_size){
+ struct gfs_log_header *lh;
+ char *p;
+
+ bh = bget(sdp, first); /* Zeroes the block */
+ lh = (struct gfs_log_header *)bh->b_data;
+
+ lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
+ lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
+ lh->lh_header.__pad0 = cpu_to_be64(0x101674); /* mh_generation */
+ lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT);
+ lh->lh_first = cpu_to_be64(first);
+ lh->lh_sequence = cpu_to_be64(sequence);
+
+ p = bh->b_data + GFS2_BASIC_BLOCK - sizeof(struct gfs_log_header);
+ memcpy(p, bh->b_data, sizeof(struct gfs_log_header));
+ bmodified(bh);
brelse(bh);
if (++sequence == ji_nsegment)
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index a9ff85bd..338f2a0a 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -172,7 +172,7 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
*/
int add_inode_to_lf(struct gfs2_inode *ip){
char tmp_name[256];
- __be32 inode_type;
+ unsigned inode_type;
struct gfs2_sbd *sdp = ip->i_sbd;
struct lgfs2_inum no;
int err = 0;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index edeaed88..4f36fe63 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -663,7 +663,7 @@ static int u64cmp(const void *p1, const void *p2)
return 0;
}
-static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
+static void dir_leaf_reada(struct gfs2_inode *ip, __be64 *tbl, unsigned hsize)
{
uint64_t *t = alloca(hsize * sizeof(uint64_t));
uint64_t leaf_no;
@@ -692,7 +692,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
int lindex;
struct gfs2_sbd *sdp = ip->i_sbd;
int ref_count, orig_ref_count, orig_di_depth, orig_di_height;
- uint64_t *tbl;
+ __be64 *tbl;
int chained_leaf, tbl_valid;
tbl = get_dir_hash(ip);
@@ -846,7 +846,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
struct metawalk_fxns *pass)
{
struct gfs2_ea_header *ea_hdr, *ea_hdr_prev = NULL;
- uint64_t *ea_data_ptr = NULL;
+ __be64 *ea_data_ptr = NULL;
int i;
int error = 0, err;
uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
@@ -873,7 +873,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
uint32_t tot_ealen = 0;
struct gfs2_sbd *sdp = ip->i_sbd;
- ea_data_ptr = ((uint64_t *)((char *)ea_hdr +
+ ea_data_ptr = ((__be64 *)((char *)ea_hdr +
sizeof(struct gfs2_ea_header) +
((ea_hdr->ea_name_len + 7) & ~7)));
@@ -962,7 +962,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
struct metawalk_fxns *pass)
{
int error = 0, err;
- uint64_t *ea_leaf_ptr, *end;
+ __be64 *ea_leaf_ptr, *end;
uint64_t block;
struct gfs2_sbd *sdp = ip->i_sbd;
int first_ea_is_bad = 0;
@@ -970,7 +970,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
uint64_t offset = ip->i_sbd->gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
int leaf_pointers = 0, leaf_pointer_errors = 0;
- ea_leaf_ptr = (uint64_t *)(indirect_buf->b_data + offset);
+ ea_leaf_ptr = (__be64 *)(indirect_buf->b_data + offset);
end = ea_leaf_ptr + ((sdp->sd_bsize - offset) / 8);
while (*ea_leaf_ptr && (ea_leaf_ptr < end)){
@@ -1112,11 +1112,12 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
int head_size, int maxptrs, int h)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- uint64_t *p, sblock = 0, block;
+ uint64_t sblock = 0, block;
int extlen = 0;
+ __be64 *p;
if (h + 2 == ip->i_height) {
- p = (uint64_t *)(bh->b_data + head_size);
+ p = (__be64 *)(bh->b_data + head_size);
if (*p && *(p + 1)) {
sblock = be64_to_cpu(*p);
p++;
@@ -1132,8 +1133,8 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
extlen = 0;
}
- for (p = (uint64_t *)(bh->b_data + head_size);
- p < (uint64_t *)(bh->b_data + sdp->sd_bsize); p++) {
+ for (p = (__be64 *)(bh->b_data + head_size);
+ p < (__be64 *)(bh->b_data + sdp->sd_bsize); p++) {
if (*p) {
if (!sblock) {
sblock = be64_to_cpu(*p);
@@ -1225,9 +1226,9 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
uint32_t height = ip->i_height;
struct gfs2_buffer_head *metabh = ip->i_bh;
osi_list_t *prev_list, *cur_list, *tmp;
- struct iptr iptr = { .ipt_ip = ip, 0};
+ struct iptr iptr = { .ipt_ip = ip, NULL, 0};
int h, head_size, iblk_type;
- uint64_t *undoptr;
+ __be64 *undoptr;
int maxptrs;
int error;
@@ -1308,7 +1309,7 @@ error_undo: /* undo what we've done so far for this block */
log_info(_("Undoing the work we did before the error on block %"PRIu64" (0x%"PRIx64").\n"),
iptr.ipt_bh->b_blocknr, iptr.ipt_bh->b_blocknr);
- for (undoptr = (uint64_t *)(iptr_buf(iptr) + head_size);
+ for (undoptr = (__be64 *)(iptr_buf(iptr) + head_size);
undoptr < iptr_ptr(iptr) && undoptr < iptr_endptr(iptr);
undoptr++) {
uint64_t block = be64_to_cpu(*undoptr);
@@ -1398,8 +1399,8 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
{
int error = 0, rc = 0;
uint64_t block;
- __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->sd_bsize);
+ __be64 *ptr_start = (__be64 *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (__be64 *)(bh->b_data + ip->i_sbd->sd_bsize);
__be64 *ptr;
uint64_t metablock = bh->b_blocknr;
@@ -1464,8 +1465,8 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
{
- __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->sd_bsize);
+ __be64 *ptr_start = (__be64 *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (__be64 *)(bh->b_data + ip->i_sbd->sd_bsize);
__be64 *ptr;
uint64_t metablock = bh->b_blocknr;
int rc = 0;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index a1038854..6e4bcad6 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -48,9 +48,9 @@ struct iptr {
unsigned ipt_off;
};
-#define iptr_ptr(i) ((uint64_t *)(i.ipt_bh->b_data + i.ipt_off))
+#define iptr_ptr(i) ((__be64 *)(i.ipt_bh->b_data + i.ipt_off))
#define iptr_block(i) be64_to_cpu(*iptr_ptr(i))
-#define iptr_endptr(i) ((uint64_t *)(iptr.ipt_bh->b_data + i.ipt_ip->i_sbd->sd_bsize))
+#define iptr_endptr(i) ((__be64 *)(iptr.ipt_bh->b_data + i.ipt_ip->i_sbd->sd_bsize))
#define iptr_buf(i) (i.ipt_bh->b_data)
/* metawalk_fxns: function pointers to check various parts of the fs
@@ -114,7 +114,7 @@ struct metawalk_fxns {
struct gfs2_ea_header *ea_hdr_prev,
void *private);
int (*check_eattr_extentry) (struct gfs2_inode *ip, int i,
- uint64_t *ea_data_ptr,
+ __be64 *ea_data_ptr,
struct gfs2_buffer_head *leaf_bh,
uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
@@ -123,7 +123,7 @@ struct metawalk_fxns {
int (*finish_eattr_indir) (struct gfs2_inode *ip, int leaf_pointers,
int leaf_pointer_errors, void *private);
void (*big_file_msg) (struct gfs2_inode *ip, uint64_t blks_checked);
- int (*check_hash_tbl) (struct gfs2_inode *ip, uint64_t *tbl,
+ int (*check_hash_tbl) (struct gfs2_inode *ip, __be64 *tbl,
unsigned hsize, void *private);
int (*repair_leaf) (struct gfs2_inode *ip, uint64_t *leaf_no,
int lindex, int ref_count, const char *msg);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 465cbceb..b283c752 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -60,7 +60,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
struct gfs2_ea_header *ea_hdr_prev,
void *private);
static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
- uint64_t *data_ptr,
+ __be64 *data_ptr,
struct gfs2_buffer_head *leaf_bh,
uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
@@ -817,7 +817,7 @@ static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
* Returns: 0 if correct[able], -1 if removal is needed
*/
static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
- uint64_t *data_ptr,
+ __be64 *data_ptr,
struct gfs2_buffer_head *leaf_bh,
uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
@@ -1705,7 +1705,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
for (i = 0; i < n; i++) {
int is_inode;
- uint32_t check_magic;
+ __be32 check_magic;
block = ibuf[i];
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index dd7653b9..ad997b56 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -43,7 +43,7 @@ struct meta_blk_ref {
static int clone_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr);
+ struct gfs2_buffer_head *bh, __be64 *ptr);
static void log_inode_reference(struct duptree *dt, osi_list_t *tmp, int inval)
{
@@ -85,7 +85,7 @@ static int findref_data(struct gfs2_inode *ip, uint64_t metablock,
if (block == mbr->block) {
mbr->metablock = bh->b_blocknr;
- mbr->off = (ptr - (uint64_t *)bh->b_data);
+ mbr->off = (ptr - (__be64 *)bh->b_data);
log_debug("Duplicate data reference located on metadata "
"block 0x%llx, offset 0x%x\n",
(unsigned long long)mbr->metablock, mbr->off);
@@ -105,7 +105,7 @@ static void clone_data_block(struct gfs2_sbd *sdp, struct duptree *dt,
struct clone_target clone = {.dup_block = dt->block,};
struct gfs2_inode *ip;
struct gfs2_buffer_head *bh;
- uint64_t *ptr;
+ __be64 *ptr;
if (!(query(_("Okay to clone data block %lld (0x%llx) for inode "
"%lld (0x%llx)? (y/n) "),
@@ -125,7 +125,7 @@ static void clone_data_block(struct gfs2_sbd *sdp, struct duptree *dt,
bh = bread(sdp, metaref.metablock);
else
bh = ip->i_bh;
- ptr = (uint64_t *)bh->b_data + metaref.off;
+ ptr = (__be64 *)bh->b_data + metaref.off;
clone_data(ip, 0, dt->block, &clone, bh, ptr);
if (metaref.metablock != id->block_no)
brelse(bh);
@@ -644,7 +644,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
osi_list_t *tmp;
struct dup_handler dh = {0};
struct gfs2_buffer_head *bh;
- uint32_t cmagic, ctype;
+ __be32 cmagic, ctype;
enum dup_ref_type acceptable_ref;
uint64_t dup_blk;
@@ -836,7 +836,7 @@ static int check_eattr_entry_refs(struct gfs2_inode *ip,
}
static int check_eattr_extentry_refs(struct gfs2_inode *ip, int i,
- uint64_t *ea_data_ptr,
+ __be64 *ea_data_ptr,
struct gfs2_buffer_head *leaf_bh,
uint32_t tot_ealen,
struct gfs2_ea_header *ea_hdr,
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 6592edaf..67833491 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -300,7 +300,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct lgfs2_inum *entry,
struct gfs2_buffer_head *dest_lbh;
uint64_t planned_leaf, real_leaf;
int li, dest_ref, error;
- uint64_t *tbl;
+ __be64 *tbl;
int di_depth;
log_err(_("Directory entry '%s' at block %"PRIu64" (0x%"PRIx64") is on the wrong leaf block.\n"),
@@ -938,12 +938,11 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
struct gfs2_dirent *dent;
int count, i;
int factor = 0, pad_size;
- uint64_t *cpyptr;
- char *padbuf;
+ __be64 *padbuf, *cpyptr;
int divisor = num_copies;
int end_lindex = start_lindex + num_copies;
- padbuf = malloc(num_copies * sizeof(uint64_t));
+ padbuf = calloc(num_copies, sizeof(__be64));
/* calculate the depth needed for the new leaf */
while (divisor > 1) {
factor++;
@@ -992,7 +991,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
brelse(nbh);
/* pad the hash table with the new leaf block */
- cpyptr = (uint64_t *)padbuf;
+ cpyptr = padbuf;
for (i = start_lindex; i < end_lindex; i++) {
*cpyptr = cpu_to_be64(*bn);
cpyptr++;
@@ -1024,7 +1023,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
* @lindex: index location within the hash table to pad
* @len: number of pointers to be padded
*/
-static void pad_with_leafblks(struct gfs2_inode *ip, uint64_t *tbl,
+static void pad_with_leafblks(struct gfs2_inode *ip, __be64 *tbl,
int lindex, int len)
{
int new_len, i;
@@ -1075,7 +1074,7 @@ static void pad_with_leafblks(struct gfs2_inode *ip, uint64_t *tbl,
* directory entries to lost+found so we don't overwrite the good leaf. Then
* we need to pad the gap we leave.
*/
-static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
+static int lost_leaf(struct gfs2_inode *ip, __be64 *tbl, uint64_t leafno,
int ref_count, int lindex, struct gfs2_buffer_head *bh)
{
char *filename;
@@ -1292,7 +1291,7 @@ static struct metawalk_fxns leafck_fxns = {
*
* Returns: 0 - no changes made, or X if changes were made
*/
-static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
+static int fix_hashtable(struct gfs2_inode *ip, __be64 *tbl, unsigned hsize,
uint64_t leafblk, int lindex, uint32_t proper_start,
int len, int *proper_len, int factor)
{
@@ -1471,7 +1470,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
}
/* check_hash_tbl_dups - check for the same leaf in multiple places */
-static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
+static int check_hash_tbl_dups(struct gfs2_inode *ip, __be64 *tbl,
unsigned hsize, int lindex, int len)
{
int l, len2;
@@ -1590,7 +1589,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
* we may need to reference leaf blocks to fix it, which means we need
* to check and/or fix a leaf block along the way.
*/
-static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
+static int check_hash_tbl(struct gfs2_inode *ip, __be64 *tbl,
unsigned hsize, void *private)
{
int error = 0;
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 762266df..7ea2dfb8 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -575,11 +575,11 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
return 0;
}
-uint64_t *get_dir_hash(struct gfs2_inode *ip)
+__be64 *get_dir_hash(struct gfs2_inode *ip)
{
unsigned hsize = (1 << ip->i_depth) * sizeof(uint64_t);
int ret;
- uint64_t *tbl = malloc(hsize);
+ __be64 *tbl = malloc(hsize);
if (tbl == NULL)
return NULL;
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index d56bb24b..88b6aa35 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -128,7 +128,7 @@ extern char generic_interrupt(const char *caller, const char *where,
const char *answers);
extern char gfs2_getch(void);
extern uint64_t find_free_blk(struct gfs2_sbd *sdp);
-extern uint64_t *get_dir_hash(struct gfs2_inode *ip);
+extern __be64 *get_dir_hash(struct gfs2_inode *ip);
extern void delete_all_dups(struct gfs2_inode *ip);
extern void print_pass_duration(const char *name, struct timeval *start);
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 272f5572..850d7217 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -163,7 +163,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
brelse(bh);
}
-int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
+int gfs1_writei(struct gfs2_inode *ip, void *buf, uint64_t offset,
unsigned int size)
{
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -222,7 +222,7 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
memcpy(bh->b_data, &mh, sizeof(mh));
}
- memcpy(bh->b_data + offset, buf + copied, amount);
+ memcpy(bh->b_data + offset, (char *)buf + copied, amount);
bmodified(bh);
if (bh != ip->i_bh)
brelse(bh);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index c8ec05aa..41f83b94 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -732,7 +732,7 @@ extern void gfs1_lookup_block(struct gfs2_inode *ip,
int create, int *new, uint64_t *block);
extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
uint64_t *dblock, uint32_t *extlen, int prealloc);
-extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
+extern int gfs1_writei(struct gfs2_inode *ip, void *buf, uint64_t offset,
unsigned int size);
extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf);
extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 38/39: gfs2_edit: Fix remaining endianness sparse
warnings
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 058c919d8c0b8a6efaed7441fdd9c689e3ae644b
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 18:25:38 2021 +0100
gfs2_edit: Fix remaining endianness sparse warnings
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 7 +--
gfs2/edit/gfs2hex.c | 11 +++--
gfs2/edit/hexedit.c | 26 ++++++-----
gfs2/edit/hexedit.h | 2 -
gfs2/edit/journal.c | 39 ++++++++--------
gfs2/edit/savemeta.c | 125 +++++++++++++++++++++++++++------------------------
6 files changed, 110 insertions(+), 100 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index d6e4624a..c2865829 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -61,7 +61,7 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
}
headoff = sbd.gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
for (x = headoff, y = 0; x < sbd.sd_bsize; x += sizeof(uint64_t), y++) {
- p = be64_to_cpu(*(uint64_t *)(diebuf + x));
+ p = be64_to_cpu(*(__be64 *)(diebuf + x));
if (p) {
iinf->ii[i_blocks].block = p;
iinf->ii[i_blocks].mp.mp_list[hgt] = i_blocks;
@@ -228,7 +228,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
return 0;
}
-static void print_inode_type(__be16 de_type)
+static void print_inode_type(uint16_t de_type)
{
if (sbd.gfs1) {
switch(de_type) {
@@ -558,7 +558,8 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
static int print_inum(struct gfs2_inode *dii)
{
- uint64_t inum, inodenum;
+ uint64_t inodenum;
+ __be64 inum;
int rc;
rc = gfs2_readi(dii, (void *)&inum, 0, sizeof(inum));
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 95572fef..219a20ea 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -49,9 +49,7 @@ int start_row[DMODES], end_row[DMODES], lines_per_row[DMODES];
int gfs2_struct_type;
unsigned int offset;
struct indirect_info masterdir;
-struct gfs2_inum gfs1_quota_di;
int print_entry_ndx;
-struct gfs2_inum gfs1_license_di;
int screen_chunk_size = 512;
uint64_t temp_blk;
int color_scheme = 0;
@@ -244,12 +242,13 @@ static int indirect_dirent(struct indirect_info *indir, void *ptr, int d)
void do_dinode_extended(char *buf)
{
struct gfs2_dinode *dip = (void *)buf;
+ struct gfs_dinode *dip1 = (void *)buf;
unsigned int x, y, ptroff = 0;
uint64_t p, last;
int isdir = 0;
if (S_ISDIR(be32_to_cpu(dip->di_mode)) ||
- (sbd.gfs1 && be16_to_cpu(dip->__pad1) == GFS_FILE_DIR))
+ (sbd.gfs1 && be16_to_cpu(dip1->di_type) == GFS_FILE_DIR))
isdir = 1;
indirect_blocks = 0;
@@ -258,7 +257,7 @@ void do_dinode_extended(char *buf)
/* Indirect pointers */
for (x = sizeof(struct gfs2_dinode); x < sbd.sd_bsize;
x += sizeof(uint64_t)) {
- p = be64_to_cpu(*(uint64_t *)(buf + x));
+ p = be64_to_cpu(*(__be64 *)(buf + x));
if (p) {
indirect->ii[indirect_blocks].block = p;
indirect->ii[indirect_blocks].mp.mp_list[0] =
@@ -289,12 +288,12 @@ void do_dinode_extended(char *buf)
dip->di_height == 0) {
/* Leaf Pointers: */
- last = be64_to_cpu(*(uint64_t *)(buf + sizeof(struct gfs2_dinode)));
+ last = be64_to_cpu(*(__be64 *)(buf + sizeof(struct gfs2_dinode)));
for (x = sizeof(struct gfs2_dinode), y = 0;
y < (1 << be16_to_cpu(dip->di_depth));
x += sizeof(uint64_t), y++) {
- p = be64_to_cpu(*(uint64_t *)(buf + x));
+ p = be64_to_cpu(*(__be64 *)(buf + x));
if (p != last || ((y + 1) * sizeof(uint64_t) == be64_to_cpu(dip->di_size))) {
struct gfs2_buffer_head *tmp_bh;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index fd7388ce..302f0843 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -40,6 +40,8 @@ static struct gfs2_buffer_head *bh;
static int pgnum;
static long int gziplevel = 9;
static int termcols;
+static struct lgfs2_inum gfs1_quota_di;
+static struct lgfs2_inum gfs1_license_di;
int details = 0;
char *device = NULL;
@@ -445,11 +447,11 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
if (sbd.gfs1) {
if (block == sbd.sd_rindex_di.in_addr)
print_gfs2("---------------- rindex file -------------------");
- else if (block == gfs1_quota_di.no_addr)
+ else if (block == gfs1_quota_di.in_addr)
print_gfs2("---------------- Quota file --------------------");
else if (block == sbd.sd_jindex_di.in_addr)
print_gfs2("--------------- Journal Index ------------------");
- else if (block == gfs1_license_di.no_addr)
+ else if (block == gfs1_license_di.in_addr)
print_gfs2("--------------- License file -------------------");
}
else {
@@ -501,13 +503,13 @@ static int hexdump(uint64_t startaddr, uint64_t len, int trunc_zeros,
const char *zeros_strt = lpBuffer + sbd.sd_bsize;
int print_field, cursor_line;
const struct lgfs2_metadata *m = get_block_type(bh->b_data);
- uint64_t *ref;
+ __be64 *ref;
int ptroffset = 0;
strcpy(edit_fmt,"%02x");
pointer = (unsigned char *)lpBuffer + offset;
ptr2 = (unsigned char *)lpBuffer + offset;
- ref = (uint64_t *)lpBuffer + offset;
+ ref = (__be64 *)lpBuffer + offset;
if (trunc_zeros) {
while (zeros_strt > lpBuffer && (*(zeros_strt - 1) == 0))
zeros_strt--;
@@ -810,11 +812,13 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
/* ------------------------------------------------------------------------ */
int has_indirect_blocks(void)
{
+ struct gfs_dinode *d1 = (struct gfs_dinode *)di;
+
if (indirect_blocks || gfs2_struct_type == GFS2_METATYPE_SB ||
gfs2_struct_type == GFS2_METATYPE_LF ||
(gfs2_struct_type == GFS2_METATYPE_DI &&
(S_ISDIR(be32_to_cpu(di->di_mode)) ||
- (sbd.gfs1 && be16_to_cpu(di->__pad1) == GFS_FILE_DIR))))
+ (sbd.gfs1 && be16_to_cpu(d1->di_type) == GFS_FILE_DIR))))
return TRUE;
return FALSE;
}
@@ -843,7 +847,7 @@ int block_is_inum_file(uint64_t blk)
int block_is_statfs_file(uint64_t blk)
{
- if (sbd.gfs1 && blk == gfs1_license_di.no_addr)
+ if (sbd.gfs1 && blk == gfs1_license_di.in_addr)
return TRUE;
if (!sbd.gfs1 && blk == masterblock("statfs"))
return TRUE;
@@ -852,7 +856,7 @@ int block_is_statfs_file(uint64_t blk)
int block_is_quota_file(uint64_t blk)
{
- if (sbd.gfs1 && blk == gfs1_quota_di.no_addr)
+ if (sbd.gfs1 && blk == gfs1_quota_di.in_addr)
return TRUE;
if (!sbd.gfs1 && blk == masterblock("quota"))
return TRUE;
@@ -1330,7 +1334,7 @@ uint64_t check_keywords(const char *kword)
blk = masterblock("inum");
else if (!strcmp(kword, "statfs")) {
if (sbd.gfs1)
- blk = gfs1_license_di.no_addr;
+ blk = gfs1_license_di.in_addr;
else
blk = masterblock("statfs");
}
@@ -1343,7 +1347,7 @@ uint64_t check_keywords(const char *kword)
blk = RGLIST_DUMMY_BLOCK;
} else if (!strcmp(kword, "quota")) {
if (sbd.gfs1)
- blk = gfs1_quota_di.no_addr;
+ blk = gfs1_quota_di.in_addr;
else
blk = masterblock("quota");
} else if (!strncmp(kword, "rg ", 3)) {
@@ -1548,7 +1552,7 @@ static void jump(void)
{
if (dmode == HEX_MODE) {
unsigned int col2;
- uint64_t *b;
+ __be64 *b;
const struct lgfs2_metadata *mtype = get_block_type(bh->b_data);
uint32_t block_type = 0;
@@ -1563,7 +1567,7 @@ static void jump(void)
temp_blk = bh->b_blocknr + pnum + 1;
} else if (edit_row[dmode] >= 0) {
col2 = edit_col[dmode] & 0x08;/* thus 0-7->0, 8-15->8 */
- b = (uint64_t *)&bh->b_data[edit_row[dmode]*16 +
+ b = (__be64 *)&bh->b_data[edit_row[dmode]*16 +
offset + col2];
temp_blk = be64_to_cpu(*b);
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index e48c5885..29f465a0 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -46,8 +46,6 @@ extern int start_row[DMODES], end_row[DMODES], lines_per_row[DMODES];
extern int edit_size[DMODES], last_entry_onscreen[DMODES];
extern char edit_fmt[80];
extern struct gfs2_sbd sbd;
-extern struct gfs2_inum gfs1_quota_di; /* kludge because gfs2 sb too small */
-extern struct gfs2_inum gfs1_license_di; /* kludge because gfs2 sb too small */
extern struct gfs2_dinode *di;
extern int screen_chunk_size; /* how much of the 4K can fit on screen */
extern int gfs2_struct_type;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index d7710c2b..ea32f9a2 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -36,7 +36,6 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
uint64_t jindex_block, jblock = 0;
int amtread;
struct gfs2_buffer_head *jindex_bh, *j_bh;
- char jbuf[sbd.sd_bsize];
journal_num = atoi(journal + 7);
if (journal_num < 0)
@@ -56,17 +55,17 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (sbd.gfs1) {
struct gfs2_inode *jiinode;
+ struct gfs_jindex jidx;
jiinode = lgfs2_inode_get(&sbd, jindex_bh);
if (jiinode == NULL)
return 0;
- amtread = gfs2_readi(jiinode, (void *)&jbuf,
+ amtread = gfs2_readi(jiinode, &jidx,
journal_num * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
if (amtread) {
- struct gfs_jindex *ji = (struct gfs_jindex *)jbuf;
- jblock = be64_to_cpu(ji->ji_addr);
- *j_size = (uint64_t)be32_to_cpu(ji->ji_nsegment) * 0x10;
+ jblock = be64_to_cpu(jidx.ji_addr);
+ *j_size = (uint64_t)be32_to_cpu(jidx.ji_nsegment) * 0x10;
}
inode_put(&jiinode);
} else {
@@ -174,10 +173,10 @@ static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
* This function checks a log descriptor buffer to see if it contains
* references to a given traced block, or its rgrp bitmap block.
*/
-static int ld_is_pertinent(const uint64_t *b, const char *end, uint64_t tblk,
+static int ld_is_pertinent(const __be64 *b, const char *end, uint64_t tblk,
struct rgrp_tree *rgd, uint64_t bitblk)
{
- const uint64_t *blk = b;
+ const __be64 *blk = b;
if (!tblk)
return 1;
@@ -196,7 +195,7 @@ static int ld_is_pertinent(const uint64_t *b, const char *end, uint64_t tblk,
* print_ld_blks - print all blocks given in a log descriptor
* returns: the number of block numbers it printed
*/
-static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
+static int print_ld_blks(const __be64 *b, const char *end, int start_line,
uint64_t tblk, uint64_t *tblk_off, uint64_t bitblk,
struct rgrp_tree *rgd, uint64_t abs_block, int prnt,
uint64_t *bblk_off, int is_meta_ld)
@@ -223,13 +222,12 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
if (is_meta_ld) {
j_bmap_bh = bread(&sbd, abs_block +
bcount);
- sprintf(str, "0x%llx %2s",
- (unsigned long long)be64_to_cpu(*b),
+ sprintf(str, "0x%"PRIx64" %2s",
+ be64_to_cpu(*b),
mtypes[lgfs2_get_block_type(j_bmap_bh->b_data)]);
brelse(j_bmap_bh);
} else {
- sprintf(str, "0x%llx",
- (unsigned long long)be64_to_cpu(*b));
+ sprintf(str, "0x%"PRIx64, be64_to_cpu(*b));
}
print_gfs2("%-18.18s ", str);
}
@@ -360,7 +358,7 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
uint64_t *tblk_off, uint64_t bitblk,
struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off)
{
- uint64_t *b;
+ __be64 *b;
struct gfs2_log_descriptor *ld = (void *)buf;
int ltndx, is_meta_ld = 0;
int ld_blocks = 0;
@@ -379,9 +377,9 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
"Quota", "Final Entry", "Unknown"}};
if (sbd.gfs1)
- b = (uint64_t *)(buf + sizeof(struct gfs_log_descriptor));
+ b = (__be64 *)(buf + sizeof(struct gfs_log_descriptor));
else
- b = (uint64_t *)(buf + sizeof(struct gfs2_log_descriptor));
+ b = (__be64 *)(buf + sizeof(struct gfs2_log_descriptor));
*prnt = ld_is_pertinent(b, (buf + sbd.sd_bsize), tblk, rgd, bitblk);
if (*prnt) {
@@ -418,7 +416,7 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
const struct lgfs2_metadata *mtype;
struct gfs2_buffer_head *mbh;
int structlen = 0, has_ref = 0;
- uint64_t *b;
+ __be64 *b;
struct gfs2_dinode *dinode;
mbh = bread(&sbd, abs_block);
@@ -431,7 +429,7 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
has_ref = 1;
}
}
- b = (uint64_t *)(mbh->b_data + structlen);
+ b = (__be64 *)(mbh->b_data + structlen);
while (!has_ref && mtype && (char *)b < mbh->b_data + sbd.sd_bsize) {
if (be64_to_cpu(*b) == tblk)
has_ref = 1;
@@ -452,10 +450,11 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
static uint64_t get_ldref(uint64_t abs_ld, int offset_from_ld)
{
struct gfs2_buffer_head *jbh;
- uint64_t *b, refblk;
+ uint64_t refblk;
+ __be64 *b;
jbh = bread(&sbd, abs_ld);
- b = (uint64_t *)(jbh->b_data + sizeof(struct gfs2_log_descriptor));
+ b = (__be64 *)(jbh->b_data + sizeof(struct gfs2_log_descriptor));
b += offset_from_ld - 1;
refblk = be64_to_cpu(*b);
brelse(jbh);
@@ -618,7 +617,7 @@ void dump_journal(const char *journal, int tblk)
eol(0);
} else if ((ld_blocks > 0) &&
(sbd.gfs1 || block_type == GFS2_METATYPE_LB)) {
- uint64_t *b = (uint64_t *)(buf + (sbd.gfs1 ? 0 : sizeof(struct gfs2_meta_header)));
+ __be64 *b = (__be64 *)(buf + (sbd.gfs1 ? 0 : sizeof(struct gfs2_meta_header)));
print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log descriptor"
" continuation block", abs_block,
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 473a2d03..5ccc46a8 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -32,17 +32,23 @@
/* Header for the savemeta output file */
struct savemeta_header {
#define SAVEMETA_MAGIC (0x01171970)
- uint32_t sh_magic;
+ __be32 sh_magic;
#define SAVEMETA_FORMAT (1)
- uint32_t sh_format; /* In case we want to change the layout */
- uint64_t sh_time; /* When savemeta was run */
- uint64_t sh_fs_bytes; /* Size of the fs */
+ __be32 sh_format; /* In case we want to change the layout */
+ __be64 sh_time; /* When savemeta was run */
+ __be64 sh_fs_bytes; /* Size of the fs */
uint8_t __reserved[104];
};
+struct savemeta {
+ time_t sm_time;
+ unsigned sm_format;
+ size_t sm_fs_bytes;
+};
+
struct saved_metablock {
- uint64_t blk;
- uint16_t siglen; /* significant data length */
+ __be64 blk;
+ __be16 siglen; /* significant data length */
/* This needs to be packed because old versions of gfs2_edit read and write the
individual fields separately, so the hole after siglen must be eradicated
before the struct reflects what's on disk. */
@@ -296,15 +302,17 @@ static int block_is_systemfile(uint64_t blk)
static size_t di_save_len(const char *buf, uint64_t owner)
{
const struct gfs2_dinode *dn;
+ const struct gfs_dinode *d1;
uint16_t di_height;
uint32_t di_mode;
int gfs1dir;
dn = (void *)buf;
+ d1 = (void *)buf;
di_mode = be32_to_cpu(dn->di_mode);
di_height = be16_to_cpu(dn->di_height);
/* __pad1 is di_type in gfs1 */
- gfs1dir = sbd.gfs1 && (be16_to_cpu(dn->__pad1) == GFS_FILE_DIR);
+ gfs1dir = sbd.gfs1 && (be16_to_cpu(d1->di_type) == GFS_FILE_DIR);
/* Do not save (user) data from the inode block unless they are
indirect pointers, dirents, symlinks or fs internal data */
@@ -697,8 +705,9 @@ static void save_ea_block(struct metafd *mfd, char *buf, uint64_t owner)
int e;
for (e = sizeof(struct gfs2_meta_header); e < sbd.sd_bsize; e += rec_len) {
- uint64_t blk, *b;
+ uint64_t blk;
int charoff, i;
+ __be64 *b;
ea = (void *)(buf + e);
/* ea_num_ptrs and ea_name_len are u8 so no endianness worries */
@@ -709,7 +718,7 @@ static void save_ea_block(struct metafd *mfd, char *buf, uint64_t owner)
sizeof(struct gfs2_ea_header) +
sizeof(uint64_t) - 1;
charoff /= sizeof(uint64_t);
- b = (uint64_t *)buf;
+ b = (__be64 *)buf;
b += charoff + i;
blk = be64_to_cpu(*b);
_buf = check_read_block(sbd.device_fd, blk, owner, NULL, NULL);
@@ -751,9 +760,9 @@ static void save_indirect_blocks(struct metafd *mfd, char *buf, uint64_t owner,
{
uint64_t old_block = 0, indir_block;
struct block_range *br = NULL;
- uint64_t *ptr;
+ __be64 *ptr;
- for (ptr = (uint64_t *)(buf + headsize);
+ for (ptr = (__be64 *)(buf + headsize);
(char *)ptr < (buf + sbd.sd_bsize); ptr++) {
if (!*ptr)
continue;
@@ -854,6 +863,7 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
{
struct block_range_queue indq[GFS2_MAX_META_HEIGHT] = {{NULL}};
struct gfs2_dinode *dip = (struct gfs2_dinode *)ibuf;
+ struct gfs_dinode *dip1 = (struct gfs_dinode *)ibuf;
uint16_t height;
int is_exhash;
@@ -869,7 +879,7 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
the hash table exists, and we have to save the directory data. */
is_exhash = (S_ISDIR(be32_to_cpu(dip->di_mode)) ||
- (sbd.gfs1 && be16_to_cpu(dip->__pad1) == GFS_FILE_DIR)) &&
+ (sbd.gfs1 && be16_to_cpu(dip1->di_type) == GFS_FILE_DIR)) &&
be32_to_cpu(dip->di_flags) & GFS2_DIF_EXHASH;
if (is_exhash)
height++;
@@ -1090,24 +1100,23 @@ static int save_header(struct metafd *mfd, uint64_t fsbytes)
return 0;
}
-static int parse_header(char *buf, struct savemeta_header *smh)
+static int parse_header(char *buf, struct savemeta *sm)
{
- struct savemeta_header *smh_be = (void *)buf;
+ struct savemeta_header *smh = (void *)buf;
- if (be32_to_cpu(smh_be->sh_magic) != SAVEMETA_MAGIC) {
+ if (be32_to_cpu(smh->sh_magic) != SAVEMETA_MAGIC) {
printf("No valid file header found. Falling back to old format...\n");
return 1;
}
- if (be32_to_cpu(smh_be->sh_format) > SAVEMETA_FORMAT) {
+ if (be32_to_cpu(smh->sh_format) > SAVEMETA_FORMAT) {
printf("This version of gfs2_edit is too old to restore this metadata format.\n");
return -1;
}
- smh->sh_magic = be32_to_cpu(smh_be->sh_magic);
- smh->sh_format = be32_to_cpu(smh_be->sh_format);
- smh->sh_time = be64_to_cpu(smh_be->sh_time);
- smh->sh_fs_bytes = be64_to_cpu(smh_be->sh_fs_bytes);
- printf("Metadata saved at %s", ctime((time_t *)&smh->sh_time)); /* ctime() adds \n */
- printf("File system size %.2fGB\n", smh->sh_fs_bytes / ((float)(1 << 30)));
+ sm->sm_format = be32_to_cpu(smh->sh_format);
+ sm->sm_time = be64_to_cpu(smh->sh_time);
+ sm->sm_fs_bytes = be64_to_cpu(smh->sh_fs_bytes);
+ printf("Metadata saved at %s", ctime(&sm->sm_time)); /* ctime() adds \n */
+ printf("File system size %.2fGB\n", sm->sm_fs_bytes / ((float)(1 << 30)));
return 0;
}
@@ -1206,34 +1215,35 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(0);
}
-static char *restore_block(struct metafd *mfd, struct saved_metablock *svb)
+static char *restore_block(struct metafd *mfd, uint64_t *blk, uint16_t *siglen)
{
- struct saved_metablock *svb_be;
+ struct saved_metablock *svb;
const char *errstr;
char *buf = NULL;
- svb_be = (struct saved_metablock *)(restore_buf_next(mfd, sizeof(*svb)));
- if (svb_be == NULL)
+ svb = (struct saved_metablock *)(restore_buf_next(mfd, sizeof(*svb)));
+ if (svb == NULL)
goto nobuffer;
- svb->blk = be64_to_cpu(svb_be->blk);
- svb->siglen = be16_to_cpu(svb_be->siglen);
+ *blk = be64_to_cpu(svb->blk);
+ *siglen = be16_to_cpu(svb->siglen);
- if (sbd.fssize && svb->blk >= sbd.fssize) {
+ if (sbd.fssize && *blk >= sbd.fssize) {
fprintf(stderr, "Error: File system is too small to restore this metadata.\n");
- fprintf(stderr, "File system is %llu blocks. Restore block = %llu\n",
- (unsigned long long)sbd.fssize, (unsigned long long)svb->blk);
+ fprintf(stderr, "File system is %"PRIu64" blocks. Restore block = %"PRIu64"\n",
+ sbd.fssize, *blk);
return NULL;
}
- if (svb->siglen > sbd.sd_bsize) {
+ if (*siglen > sbd.sd_bsize) {
fprintf(stderr, "Bad record length: %u for block %"PRIu64" (0x%"PRIx64").\n",
- svb->siglen, svb->blk, svb->blk);
+ *siglen, *blk, *blk);
return NULL;
}
- buf = restore_buf_next(mfd, svb->siglen);
- if (buf != NULL)
+ buf = restore_buf_next(mfd, *siglen);
+ if (buf != NULL) {
return buf;
+ }
nobuffer:
if (mfd->eof)
return NULL;
@@ -1266,7 +1276,6 @@ static int restore_super(struct metafd *mfd, void *buf, int printonly)
static int restore_data(int fd, struct metafd *mfd, int printonly)
{
- struct saved_metablock savedata = {0};
uint64_t writes = 0;
char *buf;
@@ -1277,9 +1286,11 @@ static int restore_data(int fd, struct metafd *mfd, int printonly)
}
while (TRUE) {
+ uint16_t siglen = 0;
+ uint64_t blk = 0;
char *bp;
- bp = restore_block(mfd, &savedata);
+ bp = restore_block(mfd, &blk, &siglen);
if (bp == NULL && mfd->eof)
break;
if (bp == NULL) {
@@ -1287,23 +1298,21 @@ static int restore_data(int fd, struct metafd *mfd, int printonly)
return -1;
}
if (printonly) {
- if (printonly > 1 && printonly == savedata.blk) {
- display_block_type(bp, savedata.blk, TRUE);
+ if (printonly > 1 && printonly == blk) {
+ display_block_type(bp, blk, TRUE);
display_gfs2(bp);
break;
} else if (printonly == 1) {
- print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, savedata.siglen);
- display_block_type(bp, savedata.blk, TRUE);
+ print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, siglen);
+ display_block_type(bp, blk, TRUE);
}
} else {
- report_progress(savedata.blk, 0);
- memcpy(buf, bp, savedata.siglen);
- memset(buf + savedata.siglen, 0, sbd.sd_bsize - savedata.siglen);
- if (pwrite(fd, buf, sbd.sd_bsize, savedata.blk * sbd.sd_bsize) != sbd.sd_bsize) {
- fprintf(stderr, "write error: %s from %s:%d: block %lld (0x%llx)\n",
- strerror(errno), __FUNCTION__, __LINE__,
- (unsigned long long)savedata.blk,
- (unsigned long long)savedata.blk);
+ report_progress(blk, 0);
+ memcpy(buf, bp, siglen);
+ memset(buf + siglen, 0, sbd.sd_bsize - siglen);
+ if (pwrite(fd, buf, sbd.sd_bsize, blk * sbd.sd_bsize) != sbd.sd_bsize) {
+ fprintf(stderr, "write error: %s from %s:%d: block %"PRIu64" (0x%"PRIx64")\n",
+ strerror(errno), __FUNCTION__, __LINE__, blk, blk);
free(buf);
return -1;
}
@@ -1326,8 +1335,9 @@ static void complain(const char *complaint)
"<dest file system>\n");
}
-static int restore_init(const char *path, struct metafd *mfd, struct savemeta_header *smh, int printonly)
+static int restore_init(const char *path, struct metafd *mfd, int printonly)
{
+ struct savemeta sm = {0};
struct gfs2_sb rsb;
uint16_t sb_siglen;
char *end;
@@ -1355,10 +1365,10 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
return -1;
}
bp = restore_buf;
- ret = parse_header(bp, smh);
+ ret = parse_header(bp, &sm);
if (ret == 0) {
- bp = restore_buf + sizeof(*smh);
- restore_off = sizeof(*smh);
+ bp = restore_buf + sizeof(struct savemeta_header);
+ restore_off = sizeof(struct savemeta_header);
} else if (ret == -1) {
return -1;
}
@@ -1381,10 +1391,10 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
if (ret != 0)
return ret;
- if (smh->sh_fs_bytes > 0) {
- sbd.fssize = smh->sh_fs_bytes / sbd.sd_bsize;
+ if (sm.sm_fs_bytes > 0) {
+ sbd.fssize = sm.sm_fs_bytes / sbd.sd_bsize;
printf("Saved file system size is %"PRIu64" blocks, %.2fGB\n",
- sbd.fssize, smh->sh_fs_bytes / ((float)(1 << 30)));
+ sbd.fssize, sm.sm_fs_bytes / ((float)(1 << 30)));
}
printf("Block size is %uB\n", sbd.sd_bsize);
printf("This is gfs%c metadata.\n", sbd.gfs1 ? '1': '2');
@@ -1403,7 +1413,6 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
void restoremeta(const char *in_fn, const char *out_device, uint64_t printonly)
{
- struct savemeta_header smh = {0};
struct metafd mfd = {0};
int error;
@@ -1422,7 +1431,7 @@ void restoremeta(const char *in_fn, const char *out_device, uint64_t printonly)
optional block no */
printonly = check_keywords(out_device);
- error = restore_init(in_fn, &mfd, &smh, printonly);
+ error = restore_init(in_fn, &mfd, printonly);
if (error != 0)
exit(error);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 37/39: gfs2_convert: Fix the remaining sparse warnings
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 0a3672d3186dde004e1b9d6d3d4a0ee1799914df
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 16:26:03 2021 +0100
gfs2_convert: Fix the remaining sparse warnings
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 67 ++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 38 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index fdcdce54..99a2fa76 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -272,7 +272,7 @@ static void mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
/* actual data blocks intact. */
/* ------------------------------------------------------------------------- */
static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
- struct blocklist *blk, uint64_t *first_nonzero_ptr,
+ struct blocklist *blk, __be64 *first_nonzero_ptr,
unsigned int size)
{
uint64_t block;
@@ -503,7 +503,8 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
struct blocklist *blk, *newblk;
struct gfs2_buffer_head *bh, *dibh = ip->i_bh;
osi_list_t *tmp;
- uint64_t *ptr1, block;
+ uint64_t block;
+ __be64 *ptr1;
int h, ptrnum;
int bufsize = sbp->sd_bsize - sizeof(struct gfs_indirect);
@@ -537,7 +538,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
if (blk->height >= ip->i_height - 1)
continue;
- for (ptr1 = (uint64_t *)blk->ptrbuf, ptrnum = 0;
+ for (ptr1 = (__be64 *)blk->ptrbuf, ptrnum = 0;
ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
if (!*ptr1)
continue;
@@ -585,7 +586,7 @@ static int fix_ind_reg_or_dir(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint3
uint32_t gfs2_hgt, struct blocklist *blk, struct blocklist *blocks)
{
unsigned int len, bufsize;
- uint64_t *ptr1, *ptr2;
+ __be64 *ptr1, *ptr2;
int ptrnum;
struct metapath gfs2mp;
@@ -599,14 +600,14 @@ static int fix_ind_reg_or_dir(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint3
That's a problem if the file system is full.
So I'm trying to truncate the data at the start and end
of the buffers (i.e. write only what we need to). */
- for (ptr1 = (uint64_t *)blk->ptrbuf, ptrnum = 0;
+ for (ptr1 = (__be64 *)blk->ptrbuf, ptrnum = 0;
ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
if (*ptr1 != 0x00)
break;
len -= sizeof(uint64_t);
}
/* Skip zero bytes at the end of the buffer */
- ptr2 = (uint64_t *)(blk->ptrbuf + bufsize) - 1;
+ ptr2 = (__be64 *)(blk->ptrbuf + bufsize) - 1;
while (len > 0 && *ptr2 == 0) {
ptr2--;
len -= sizeof(uint64_t);
@@ -630,7 +631,8 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
/*FIXME: Messages here should be different, to not conflit with messages in get_inode_metablocks */
struct blocklist *newblk;
unsigned int len, bufsize;
- uint64_t *ptr1, block;
+ uint64_t block;
+ __be64 *ptr1;
int ptrnum, h;
struct metapath gfs2mp;
struct gfs2_buffer_head *bh;
@@ -640,7 +642,7 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
* For each metadata block that holds jdata block pointers,
* get the blk pointers and copy them block by block
*/
- for (ptr1 = (uint64_t *) blk->ptrbuf, ptrnum = 0;
+ for (ptr1 = (__be64 *)blk->ptrbuf, ptrnum = 0;
ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
if (!*ptr1)
continue;
@@ -1156,7 +1158,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
if (dentmod) {
if (dent->de_type == cpu_to_be16(DT_LNK)
- && cpu_to_be64(dent->de_inum.no_addr) == dentmod) {
+ && be64_to_cpu(dent->de_inum.no_addr) == dentmod) {
dent->de_type = cpu_to_be16(DT_DIR);
error = -EISDIR;
break;
@@ -1266,8 +1268,8 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
prev_leaf_block = 0;
/* for all the leafs, get the leaf block and process the dirents inside */
for (leaf_num = 0; ; leaf_num++) {
- uint64_t buf;
struct gfs2_leaf *leaf;
+ __be64 buf;
error = gfs2_readi(dip, (char *)&buf, leaf_num * sizeof(uint64_t),
sizeof(uint64_t));
@@ -1441,18 +1443,6 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
return error;
} /* fix_cdpn_symlinks */
-/* ------------------------------------------------------------------------- */
-/* Fetch gfs1 jindex structure from buffer */
-/* ------------------------------------------------------------------------- */
-static void gfs1_jindex_in(struct gfs_jindex *jindex, char *buf)
-{
- struct gfs_jindex *str = (struct gfs_jindex *)buf;
-
- jindex->ji_addr = be64_to_cpu(str->ji_addr);
- jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
- memset(jindex->ji_reserved, 0, 64);
-}
-
/* ------------------------------------------------------------------------- */
/* read_gfs1_jiindex - read the gfs1 jindex file. */
/* Returns: 0 on success, -1 on failure */
@@ -1488,7 +1478,7 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
ip->i_mode &= ~S_IFMT;
ip->i_mode |= S_IFDIR;
for (j = 0; ; j++) {
- struct gfs_jindex *journ;
+ uint32_t nseg;
error = gfs2_readi(ip, buf, j * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
@@ -1499,9 +1489,9 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
" journal index file.\n"));
goto fail;
}
- journ = sd_jindex + j;
- gfs1_jindex_in(journ, buf);
- sdp->jsize = (journ->ji_nsegment * 16 * sdp->sd_bsize) >> 20;
+ memcpy(sd_jindex + j, buf, sizeof(struct gfs_jindex));
+ nseg = be32_to_cpu(sd_jindex[j].ji_nsegment);
+ sdp->jsize = (nseg * 16 * sdp->sd_bsize) >> 20;
}
ip->i_mode = tmp_mode;
if(j * sizeof(struct gfs_jindex) != ip->i_size){
@@ -1833,7 +1823,6 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
{
int error = 0;
int j;
- struct gfs_jindex *jndx;
struct rgrp_tree *rgd, *rgdhigh;
struct osi_node *n, *next = NULL;
struct gfs2_meta_header mh = {0};
@@ -1845,9 +1834,12 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
log_notice(_("Converting journal space to rg space.\n"));
/* Go through each journal, converting them one by one */
for (j = 0; j < orig_journals; j++) { /* for each journal */
+ uint32_t ji_nsegs;
+ uint64_t ji_addr;
uint64_t size;
- jndx = &sd_jindex[j];
+ ji_nsegs = be32_to_cpu(sd_jindex[j].ji_nsegment);
+ ji_addr = be64_to_cpu(sd_jindex[j].ji_addr);
/* go through all rg index entries, keeping track of the
highest that's still in the first subdevice.
Note: we really should go through all of the rgindex because
@@ -1858,7 +1850,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- if (rgd->rt_addr < jndx->ji_addr &&
+ if (rgd->rt_addr < ji_addr &&
((rgdhigh == NULL) ||
(rgd->rt_addr > rgdhigh->rt_addr)))
rgdhigh = rgd;
@@ -1868,20 +1860,19 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
return -1;
}
log_info(_("Addr 0x%"PRIx64" comes after rg at addr 0x%"PRIx64"\n"),
- jndx->ji_addr, rgdhigh->rt_addr);
- ri_addr = jndx->ji_addr;
+ ji_addr, rgdhigh->rt_addr);
+ ri_addr = ji_addr;
/* Allocate a new rgd entry which includes rg and ri. */
rgd = rgrp_insert(&sdp->rgtree, ri_addr);
/* convert the gfs1 rgrp into a new gfs2 rgrp */
- size = jndx->ji_nsegment *
- be32_to_cpu(gfs1_sb.sb_seg_size);
+ size = ji_nsegs * be32_to_cpu(gfs1_sb.sb_seg_size);
rgd->rt_flags = 0;
rgd->rt_dinodes = 0;
- rgd->rt_addr = jndx->ji_addr; /* new rg addr becomes ji addr */
+ rgd->rt_addr = ji_addr; /* new rg addr becomes ji addr */
rgd->rt_length = rgrp_length(size, sdp); /* aka bitblocks */
- rgd->rt_data0 = jndx->ji_addr + rgd->rt_length;
+ rgd->rt_data0 = ji_addr + rgd->rt_length;
rgd->rt_data = size - rgd->rt_length;
/* Round down to nearest multiple of GFS2_NBBY */
while (rgd->rt_data & 0x03)
@@ -1921,16 +1912,16 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
static void update_inode_file(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.inum;
- uint64_t buf;
+ __be64 buf;
int count;
-
+
buf = cpu_to_be64(sdp->md.next_inum);
count = gfs2_writei(ip, &buf, 0, sizeof(uint64_t));
if (count != sizeof(uint64_t)) {
fprintf(stderr, "update_inode_file\n");
exit(1);
}
-
+
log_debug(_("\nNext Inum: %llu\n"), (unsigned long long)sdp->md.next_inum);
}/* update_inode_file */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 36/39: libgfs2: Fix the remaining sparse warnings
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit aec647ab5998699911ca3c07e1d0bfa64acffc87
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 14:55:54 2021 +0100
libgfs2: Fix the remaining sparse warnings
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 67 +++++++++++++++++++++++++++--------------------
gfs2/libgfs2/meta.c | 12 ++++-----
gfs2/libgfs2/recovery.c | 3 ++-
gfs2/libgfs2/rgrp.c | 2 +-
gfs2/libgfs2/structures.c | 9 +++----
5 files changed, 52 insertions(+), 41 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e533b9de..eb695a3e 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -14,14 +14,14 @@
#include "libgfs2.h"
#include "rgrp.h"
-static __inline__ uint64_t *metapointer(char *buf,
+static __inline__ __be64 *metapointer(char *buf,
unsigned int height,
struct metapath *mp)
{
unsigned int head_size = (height > 0) ?
sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
- return ((uint64_t *)(buf + head_size)) + mp->mp_list[height];
+ return ((__be64 *)(buf + head_size)) + mp->mp_list[height];
}
/* Detect directory is a stuffed inode */
@@ -272,7 +272,7 @@ void unstuff_dinode(struct gfs2_inode *ip)
buffer_clear_tail(sdp, ip->i_bh, sizeof(struct gfs2_dinode));
if (ip->i_size) {
- *(uint64_t *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
+ *(__be64 *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
/* no need: bmodified(ip->i_bh); buffer_clear_tail does it */
ip->i_blocks++;
}
@@ -419,7 +419,7 @@ void build_height(struct gfs2_inode *ip, int height)
buffer_clear_tail(sdp, ip->i_bh, sizeof(struct gfs2_dinode));
if (new_block) {
- *(uint64_t *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
+ *(__be64 *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
/* no need: bmodified(ip->i_bh);*/
ip->i_blocks++;
}
@@ -444,7 +444,7 @@ void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
int create, int *new, uint64_t *block)
{
- uint64_t *ptr = metapointer(bh->b_data, height, mp);
+ __be64 *ptr = metapointer(bh->b_data, height, mp);
if (*ptr) {
*block = be64_to_cpu(*ptr);
@@ -861,9 +861,10 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
bmodified(bh);
if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LF) == 0) {
struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
+ uint16_t entries;
- lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
- lf->lf_entries = cpu_to_be16(lf->lf_entries);
+ entries = be16_to_cpu(lf->lf_entries) - 1;
+ lf->lf_entries = cpu_to_be16(entries);
}
if (dip->i_entries) {
@@ -885,9 +886,9 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
int lgfs2_get_leaf_ptr(struct gfs2_inode *dip, const uint32_t lindex, uint64_t *ptr)
{
- uint64_t leaf_no;
- int count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t), sizeof(uint64_t));
- if (count != sizeof(uint64_t))
+ __be64 leaf_no;
+ int count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(__be64), sizeof(__be64));
+ if (count != sizeof(__be64))
return -1;
*ptr = be64_to_cpu(leaf_no);
@@ -901,7 +902,9 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
struct gfs2_leaf *nleaf, *oleaf;
struct gfs2_dirent *dent, *prev = NULL, *next = NULL, *new;
uint32_t len, half_len, divider;
- uint64_t bn, *lp;
+ uint16_t depth;
+ uint64_t bn;
+ __be64 *lp;
uint32_t name_len;
int x, moved = 0;
int count;
@@ -929,7 +932,7 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
len = 1 << (dip->i_depth - be16_to_cpu(oleaf->lf_depth));
half_len = len >> 1;
- lp = calloc(1, half_len * sizeof(uint64_t));
+ lp = calloc(1, half_len * sizeof(__be64));
if (lp == NULL) {
fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
exit(-1);
@@ -961,6 +964,8 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
if (dent->de_inum.no_formal_ino &&
be32_to_cpu(dent->de_hash) < divider) {
+ uint16_t entries;
+
name_len = be16_to_cpu(dent->de_name_len);
if (dirent_alloc(dip, nbh, name_len, &new)) {
@@ -973,8 +978,8 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
new->de_type = dent->de_type;
memcpy((char *)(new + 1), (char *)(dent + 1), name_len);
- nleaf->lf_entries = be16_to_cpu(nleaf->lf_entries) + 1;
- nleaf->lf_entries = cpu_to_be16(nleaf->lf_entries);
+ entries = be16_to_cpu(nleaf->lf_entries) + 1;
+ nleaf->lf_entries = cpu_to_be16(entries);
dirent2_del(dip, obh, prev, dent);
@@ -998,8 +1003,8 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
dip->i_entries--;
}
- oleaf->lf_depth = be16_to_cpu(oleaf->lf_depth) + 1;
- oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
+ depth = be16_to_cpu(oleaf->lf_depth) + 1;
+ oleaf->lf_depth = cpu_to_be16(depth);
nleaf->lf_depth = oleaf->lf_depth;
nleaf->lf_inode = cpu_to_be64(dip->i_num.in_addr);
@@ -1162,6 +1167,8 @@ restart:
return err;
for (;;) {
+ uint16_t entries;
+
bh = bread(dip->i_sbd, leaf_no);
leaf = (struct gfs2_leaf *)bh->b_data;
@@ -1220,8 +1227,8 @@ restart:
dent->de_type = cpu_to_be16(type);
memcpy((char *)(dent + 1), filename, len);
- leaf->lf_entries = be16_to_cpu(leaf->lf_entries) + 1;
- leaf->lf_entries = cpu_to_be16(leaf->lf_entries);
+ entries = be16_to_cpu(leaf->lf_entries) + 1;
+ leaf->lf_entries = cpu_to_be16(entries);
bmodified(bh);
brelse(bh);
@@ -1235,9 +1242,11 @@ static void dir_make_exhash(struct gfs2_inode *dip)
struct gfs2_dirent *dent;
struct gfs2_buffer_head *bh;
struct gfs2_leaf *leaf;
+ uint16_t rec_len;
int y;
uint32_t x;
- uint64_t *lp, bn;
+ uint64_t bn;
+ __be64 *lp;
if (lgfs2_meta_alloc(dip, &bn))
exit(1);
@@ -1269,16 +1278,16 @@ static void dir_make_exhash(struct gfs2_inode *dip)
break;
} while (gfs2_dirent_next(dip, bh, &dent) == 0);
- dent->de_rec_len = be16_to_cpu(dent->de_rec_len);
- dent->de_rec_len = cpu_to_be16(dent->de_rec_len +
- sizeof(struct gfs2_dinode) - sizeof(struct gfs2_leaf));
+ rec_len = be16_to_cpu(dent->de_rec_len) +
+ sizeof(struct gfs2_dinode) - sizeof(struct gfs2_leaf);
+ dent->de_rec_len = cpu_to_be16(rec_len);
/* no need to: bmodified(bh); (buffer_copy_tail does it) */
brelse(bh);
buffer_clear_tail(sdp, dip->i_bh, sizeof(struct gfs2_dinode));
- lp = (uint64_t *)(dip->i_bh->b_data + sizeof(struct gfs2_dinode));
+ lp = (__be64 *)(dip->i_bh->b_data + sizeof(struct gfs2_dinode));
for (x = sdp->sd_hash_ptrs; x--; lp++)
*lp = cpu_to_be64(bn);
@@ -1300,6 +1309,7 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
struct lgfs2_inum *inum, unsigned int type)
{
struct gfs2_dirent *dent;
+ uint32_t de_hash;
int err = 0;
if (dirent_alloc(dip, dip->i_bh, len, &dent)) {
@@ -1309,8 +1319,8 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
}
lgfs2_inum_out(inum, &dent->de_inum);
- dent->de_hash = gfs2_disk_hash(filename, len);
- dent->de_hash = cpu_to_be32(dent->de_hash);
+ de_hash = gfs2_disk_hash(filename, len);
+ dent->de_hash = cpu_to_be32(de_hash);
dent->de_type = cpu_to_be16(type);
memcpy((char *)(dent + 1), filename, len);
bmodified(dip->i_bh);
@@ -1418,7 +1428,7 @@ static void lgfs2_fill_indir(char *start, char *end, uint64_t ptr0, unsigned n,
memset(start, 0, end - start);
for (bp = start; bp < end && *p < n; bp += sizeof(uint64_t)) {
uint64_t pn = ptr0 + *p;
- *(uint64_t *)bp = cpu_to_be64(pn);
+ *(__be64 *)bp = cpu_to_be64(pn);
(*p)++;
}
}
@@ -1918,9 +1928,10 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
struct gfs2_inode *ip;
struct gfs2_buffer_head *bh, *nbh;
int h, head_size;
- uint64_t *ptr, block;
+ uint64_t block;
struct rgrp_tree *rgd;
uint32_t height;
+ __be64 *ptr;
osi_list_t metalist[GFS2_MAX_META_HEIGHT];
osi_list_t *cur_list, *next_list, *tmp;
@@ -1946,7 +1957,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
bh = osi_list_entry(tmp, struct gfs2_buffer_head,
b_altlist);
- for (ptr = (uint64_t *)(bh->b_data + head_size);
+ for (ptr = (__be64 *)(bh->b_data + head_size);
(char *)ptr < (bh->b_data + sdp->sd_bsize); ptr++) {
if (!*ptr)
continue;
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index db5f37b1..5d8811a6 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -873,13 +873,13 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk, const struct
value = *(uint8_t *)fieldp;
break;
case sizeof(uint16_t):
- value = be16_to_cpu(*(uint16_t *)fieldp);
+ value = be16_to_cpu(*(__be16 *)fieldp);
break;
case sizeof(uint32_t):
- value = be32_to_cpu(*(uint32_t *)fieldp);
+ value = be32_to_cpu(*(__be32 *)fieldp);
break;
case sizeof(uint64_t):
- value = be64_to_cpu(*(uint64_t *)fieldp);
+ value = be64_to_cpu(*(__be64 *)fieldp);
break;
default:
*str = 0;
@@ -948,13 +948,13 @@ int lgfs2_field_assign(char *blk, const struct lgfs2_metafield *field, const voi
*fieldp = (uint8_t)num;
return 0;
case sizeof(uint16_t):
- *(uint16_t *)fieldp = cpu_to_be16((uint16_t)num);
+ *(__be16 *)fieldp = cpu_to_be16((uint16_t)num);
return 0;
case sizeof(uint32_t):
- *(uint32_t *)fieldp = cpu_to_be32((uint32_t)num);
+ *(__be32 *)fieldp = cpu_to_be32((uint32_t)num);
return 0;
case sizeof(uint64_t):
- *(uint64_t *)fieldp = cpu_to_be64((uint64_t)num);
+ *(__be64 *)fieldp = cpu_to_be64((uint64_t)num);
return 0;
default:
/* Will never happen */
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 9234a867..f4cea511 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -71,7 +71,8 @@ int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
struct gfs2_buffer_head *bh;
struct lgfs2_log_header lh;
struct gfs2_log_header *tmp;
- uint32_t hash, saved_hash;
+ __be32 saved_hash;
+ uint32_t hash;
uint32_t lh_crc = 0;
uint32_t crc;
int error;
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index b7f5f1de..94907c25 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -157,7 +157,7 @@ int lgfs2_rgrp_crc_check(char *buf)
{
int ret = 0;
struct gfs2_rgrp *rg = (struct gfs2_rgrp *)buf;
- uint32_t crc = rg->rg_crc;
+ __be32 crc = rg->rg_crc;
if (crc == 0)
return 0;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index ae5de7e1..a562dc50 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -589,7 +589,7 @@ int build_root(struct gfs2_sbd *sdp)
int do_init_inum(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.inum;
- uint64_t buf;
+ __be64 buf;
int count;
buf = cpu_to_be64(sdp->md.next_inum);
@@ -626,11 +626,10 @@ int do_init_statfs(struct gfs2_sbd *sdp)
int gfs2_check_meta(const char *buf, int type)
{
- uint32_t check_magic = ((struct gfs2_meta_header *)buf)->mh_magic;
- uint32_t check_type = ((struct gfs2_meta_header *)buf)->mh_type;
+ struct gfs2_meta_header *mh = (struct gfs2_meta_header *)buf;
+ uint32_t check_magic = be32_to_cpu(mh->mh_magic);
+ uint32_t check_type = be32_to_cpu(mh->mh_type);
- check_magic = be32_to_cpu(check_magic);
- check_type = be32_to_cpu(check_type);
if((check_magic != GFS2_MAGIC) || (type && (check_type != type)))
return -1;
return 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 35/39: fsck.gfs2: Remove unused invalidate_fxns
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 5cbbc5cc53378d597c76b17041bdf1170638f4f2
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 14:01:12 2021 +0100
fsck.gfs2: Remove unused invalidate_fxns
Introduced in 00f523c4 "fsck.gfs2: invalidate invalid mode inodes"
Unused since 5e7c6711 "fsck.gfs2: Do not invalidate metablocks of
dinodes with invalid mode"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/pass1.c | 101 ------------------------------------------------------
1 file changed, 101 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index d619a972..465cbceb 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -997,107 +997,6 @@ static int check_eattr_entries(struct gfs2_inode *ip,
return 0;
}
-/**
- * mark_block_invalid - mark blocks associated with an inode as invalid
- * unless the block is a duplicate.
- *
- * An "invalid" block is now considered free in the bitmap, and pass2 will
- * delete any invalid blocks. This is nearly identical to function
- * delete_block_if_notdup.
- */
-static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
- enum dup_ref_type reftype, const char *btype,
- int *is_valid, int *was_duplicate)
-{
- int q;
-
- /* If the block isn't valid, we obviously can't invalidate it.
- * However, if we return an error, invalidating will stop, and
- * we want it to continue to invalidate the valid blocks. If we
- * don't do this, block references that follow that are also
- * referenced elsewhere (duplicates) won't be flagged as such,
- * and as a result, they'll be freed when this dinode is deleted,
- * despite being used by another dinode as a valid block. */
- if (is_valid)
- *is_valid = 1;
- if (was_duplicate)
- *was_duplicate = 0;
- if (!valid_block_ip(ip, block)) {
- if (is_valid)
- *is_valid = 0;
- return META_IS_GOOD;
- }
-
- q = block_type(bl, block);
- if (q != GFS2_BLKST_FREE) {
- if (was_duplicate)
- *was_duplicate = 1;
- add_duplicate_ref(ip, block, reftype, 0, INODE_INVALID);
- log_info(_("%s block %"PRIu64" (0x%"PRIx64"), part of inode "
- "%"PRIu64" (0x%"PRIx64"), was previously referenced so "
- "the invalid reference is ignored.\n"),
- btype, block, block, ip->i_num.in_addr, ip->i_num.in_addr);
- return META_IS_GOOD;
- }
- fsck_blockmap_set(ip, block, btype, GFS2_BLKST_UNLINKED);
- return META_IS_GOOD;
-}
-
-static int invalidate_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate, void *private)
-{
- struct gfs2_inode *ip = iptr.ipt_ip;
- uint64_t block = iptr_block(iptr);
-
- *is_valid = 1;
- *was_duplicate = 0;
- return mark_block_invalid(ip, block, REF_AS_META, _("metadata"),
- is_valid, was_duplicate);
-}
-
-static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
- void *private)
-{
- return mark_block_invalid(ip, block, REF_AS_META, _("leaf"),
- NULL, NULL);
-}
-
-static int invalidate_data(struct gfs2_inode *ip, uint64_t metablock,
- uint64_t block, void *private,
- struct gfs2_buffer_head *bh, __be64 *ptr)
-{
- return mark_block_invalid(ip, block, REF_AS_DATA, _("data"),
- NULL, NULL);
-}
-
-static int invalidate_eattr_indir(struct gfs2_inode *ip, uint64_t block,
- uint64_t parent,
- struct gfs2_buffer_head **bh, void *private)
-{
- return mark_block_invalid(ip, block, REF_AS_EA,
- _("indirect extended attribute"),
- NULL, NULL);
-}
-
-static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
- uint64_t parent, struct gfs2_buffer_head **bh,
- void *private)
-{
- return mark_block_invalid(ip, block, REF_AS_EA,
- _("extended attribute"),
- NULL, NULL);
-}
-
-static struct metawalk_fxns invalidate_fxns = {
- .private = NULL,
- .check_metalist = invalidate_metadata,
- .check_data = invalidate_data,
- .check_leaf = invalidate_leaf,
- .check_eattr_indir = invalidate_eattr_indir,
- .check_eattr_leaf = invalidate_eattr_leaf,
- .delete_block = delete_block,
-};
-
/**
* Check for massive amounts of pointer corruption. If the block has
* lots of out-of-range pointers, we can't trust any of the pointers.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 34/39: Fix sparse warnings about linkage
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 91ee909c3ee541009460359536d26eb1ab1c315e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 13:57:22 2021 +0100
Fix sparse warnings about linkage
Fixes a bajillion cases of "warning: symbol '<symbol>' was not declared.
Should it be static?"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 37 +++++++++++++++--------------
gfs2/edit/extended.c | 2 --
gfs2/edit/gfs2hex.c | 4 ++--
gfs2/edit/gfs2hex.h | 1 +
gfs2/edit/hexedit.c | 16 ++++---------
gfs2/edit/hexedit.h | 1 +
gfs2/edit/journal.c | 2 --
gfs2/edit/savemeta.c | 9 ++++---
gfs2/fsck/fs_recovery.c | 16 +++++++------
gfs2/fsck/fsck.h | 1 +
gfs2/fsck/initialize.c | 1 -
gfs2/fsck/main.c | 13 ++++++-----
gfs2/fsck/pass1.c | 18 +++++++-------
gfs2/fsck/pass2.c | 12 +++++-----
gfs2/fsck/pass4.c | 2 +-
gfs2/fsck/rgrepair.c | 4 ++--
gfs2/glocktop/glocktop.c | 57 ++++++++++++++++++++++-----------------------
gfs2/mkfs/main_mkfs.c | 2 +-
gfs2/tune/main.c | 5 ++--
tests/nukerg.c | 2 +-
20 files changed, 99 insertions(+), 106 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 5228c532..fdcdce54 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -94,24 +94,25 @@ struct gfs2_options {
unsigned int query:1;
};
-struct gfs_sb gfs1_sb;
-struct gfs2_sbd sb2;
-struct inode_block dirs_to_fix; /* linked list of directories to fix */
-struct inode_dir_block cdpns_to_fix; /* linked list of cdpn symlinks */
-int seconds;
-struct timeval tv;
-uint64_t dirs_fixed;
-uint64_t cdpns_fixed;
-uint64_t dirents_fixed;
-struct gfs_jindex *sd_jindex = NULL; /* gfs1 journal index in memory */
-int gfs2_inptrs;
-uint64_t gfs2_heightsize[GFS2_MAX_META_HEIGHT];
-uint64_t gfs2_jheightsize[GFS2_MAX_META_HEIGHT];
-uint32_t gfs2_max_height;
-uint32_t gfs2_max_jheight;
-uint64_t jindex_addr = 0, rindex_addr = 0;
+static struct gfs_sb gfs1_sb;
+static struct gfs2_sbd sb2;
+static struct inode_block dirs_to_fix; /* linked list of directories to fix */
+static struct inode_dir_block cdpns_to_fix; /* linked list of cdpn symlinks */
+static int seconds;
+static struct timeval tv;
+static uint64_t dirs_fixed;
+static uint64_t cdpns_fixed;
+static uint64_t dirents_fixed;
+static struct gfs_jindex *sd_jindex = NULL; /* gfs1 journal index in memory */
+static int gfs2_inptrs;
+static uint64_t gfs2_heightsize[GFS2_MAX_META_HEIGHT];
+static uint64_t gfs2_jheightsize[GFS2_MAX_META_HEIGHT];
+static uint32_t gfs2_max_height;
+static uint32_t gfs2_max_jheight;
+static uint64_t jindex_addr = 0, rindex_addr = 0;
+static unsigned orig_journals = 0;
+
int print_level = MSG_NOTICE;
-unsigned orig_journals = 0;
/* ------------------------------------------------------------------------- */
/* This function is for libgfs's sake. */
@@ -773,7 +774,7 @@ out:
return error;
}
-const char *cdpn[14] = {"{hostname}", "{mach}", "{os}", "{uid}", "{gid}", "{sys}", "{jid}",
+static const char *cdpn[14] = {"{hostname}", "{mach}", "{os}", "{uid}", "{gid}", "{sys}", "{jid}",
"@hostname", "@mach", "@os", "@uid", "@gid", "@sys", "@jid"};
static int has_cdpn(const char *str)
{
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 92dbb415..d6e4624a 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -25,8 +25,6 @@
#include "extended.h"
#include "gfs2hex.h"
-extern uint64_t block;
-
static void print_block_details(struct iinfo *ind, int level, int cur_height,
int pndx, uint64_t file_offset);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index d1878639..95572fef 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -28,7 +28,7 @@
} while(0)
struct gfs2_dinode *di;
-int line, termlines, modelines[DMODES];
+int line, termlines;
char edit_fmt[80];
char estring[1024];
char efield[64];
@@ -63,7 +63,7 @@ const char *termtype;
WINDOW *wind;
int dsplines = 0;
-const char *block_type_str[15] = {
+static const char *block_type_str[15] = {
"Clump",
"Superblock",
"Resource Group Header",
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index a86e3a4c..14230ffa 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -9,5 +9,6 @@ extern void do_dinode_extended(char *buf);
extern void print_gfs2(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
extern uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir);
extern void eol(int col);
+extern uint64_t block;
#endif /* __GFS2HEX_DOT_H__ */
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 00f5aa03..fd7388ce 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -36,19 +36,13 @@ const char *allocdesc[2][5] = {
{"Free ", "Data ", "Unlnk", "Meta ", "Resrv"},
{"Free ", "Data ", "FreeM", "Meta ", "Resrv"},};
-struct gfs2_buffer_head *bh;
-struct gfs2_rgrp *lrgrp;
-struct gfs2_meta_header *lmh;
-struct gfs2_dinode *ldi;
-struct gfs2_leaf *lleaf;
-struct gfs2_log_header *llh;
-struct gfs2_log_descriptor *lld;
-int pgnum;
-int details = 0;
-long int gziplevel = 9;
+static struct gfs2_buffer_head *bh;
+static int pgnum;
+static long int gziplevel = 9;
static int termcols;
+
+int details = 0;
char *device = NULL;
-extern uint64_t block;
/* ------------------------------------------------------------------------- */
/* erase - clear the screen */
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index adbeb742..e48c5885 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -62,6 +62,7 @@ extern int dsp_lines[DMODES];
extern int combined_display;
extern int details;
extern const char *allocdesc[2][5];
+extern char *device;
struct idirent {
struct lgfs2_inum inum;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 1baba02f..d7710c2b 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -26,8 +26,6 @@
#include "gfs2hex.h"
#include "journal.h"
-extern uint64_t block;
-
/**
* find_journal_block - figure out where a journal starts, given the name
* Returns: journal block number, changes j_size to the journal size
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index a99930c2..473a2d03 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -60,9 +60,9 @@ struct metafd {
const char* (*strerr)(struct metafd *mfd);
};
-char *restore_buf;
-ssize_t restore_left;
-off_t restore_off;
+static char *restore_buf;
+static ssize_t restore_left;
+static off_t restore_off;
#define RESTORE_BUF_SIZE (2 * 1024 * 1024)
static char *restore_buf_next(struct metafd *mfd, size_t required_len)
@@ -184,7 +184,6 @@ static uint64_t journal_blocks[MAX_JOURNALS_SAVED];
static uint64_t gfs1_journal_size = 0; /* in blocks */
static int journals_found = 0;
int print_level = MSG_NOTICE;
-extern char *device;
static int block_is_a_journal(uint64_t blk)
{
@@ -196,7 +195,7 @@ static int block_is_a_journal(uint64_t blk)
return FALSE;
}
-struct osi_root per_node_tree;
+static struct osi_root per_node_tree;
struct per_node_node {
struct osi_node node;
uint64_t block;
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index e6744dc2..b62f7a65 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -19,11 +19,13 @@
#define JOURNAL_NAME_SIZE 18
#define JOURNAL_SEQ_TOLERANCE 10
-unsigned int sd_found_jblocks = 0, sd_replayed_jblocks = 0;
-unsigned int sd_found_metablocks = 0, sd_replayed_metablocks = 0;
-unsigned int sd_found_revokes = 0;
-osi_list_t sd_revoke_list;
-unsigned int sd_replay_tail;
+static unsigned int sd_found_jblocks = 0;
+static unsigned int sd_replayed_jblocks = 0;
+static unsigned int sd_found_metablocks = 0;
+static unsigned int sd_replayed_metablocks = 0;
+static unsigned int sd_found_revokes = 0;
+static osi_list_t sd_revoke_list;
+static unsigned int sd_replay_tail;
struct gfs2_revoke_replay {
osi_list_t rr_list;
@@ -666,7 +668,7 @@ static int rangecheck_jdata(struct gfs2_inode *ip, uint64_t metablock,
return rangecheck_jblock(ip, block);
}
-struct metawalk_fxns rangecheck_journal = {
+static struct metawalk_fxns rangecheck_journal = {
.private = NULL,
.invalid_meta_is_fatal = 1,
.check_metalist = rangecheck_jmeta,
@@ -854,7 +856,7 @@ dirent_good:
return 0;
}
-struct metawalk_fxns jindex_check_fxns = {
+static struct metawalk_fxns jindex_check_fxns = {
.private = NULL,
.check_dentry = check_jindex_dent,
};
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 55f5abe8..91ef23d1 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -199,5 +199,6 @@ struct special_blocks {
extern struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num);
extern void gfs2_special_set(struct special_blocks *blocklist, uint64_t block);
extern void gfs2_special_free(struct special_blocks *blist);
+extern int sb_fixed;
#endif /* _FSCK_H */
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 039a0fd7..4bc7eef6 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -34,7 +34,6 @@ static int was_mounted_ro = 0;
static uint64_t possible_root = HIGHEST_BLOCK;
static struct master_dir fix_md;
static unsigned long long blks_2free = 0;
-extern int sb_fixed;
/**
* block_mounters
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index a7ea9bf2..b528b5ee 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -32,18 +32,19 @@ uint64_t last_fs_block, last_reported_block = -1;
int64_t last_reported_fblock = -1000000;
int skip_this_pass = 0, fsck_abort = 0;
int errors_found = 0, errors_corrected = 0;
-const char *pass = "";
uint64_t last_data_block;
uint64_t first_data_block;
-int preen = 0, force_check = 0;
struct osi_root dup_blocks;
struct osi_root dirtree;
struct osi_root inodetree;
int dups_found = 0, dups_found_first = 0;
-struct gfs_sb *sbd1 = NULL;
int sb_fixed = 0;
int print_level = MSG_NOTICE;
+static int preen = 0;
+static int force_check = 0;
+static const char *pass_name = "";
+
/* This function is for libgfs2's sake. */
void print_it(const char *label, const char *fmt, const char *fmt2, ...)
{
@@ -148,8 +149,8 @@ static void interrupt(int sig)
sprintf(progress, _("processing block %llu out of %llu\n"),
(unsigned long long)last_reported_block,
(unsigned long long)last_fs_block);
-
- response = generic_interrupt("fsck.gfs2", pass, progress,
+
+ response = generic_interrupt("fsck.gfs2", pass_name, progress,
_("Do you want to abort fsck.gfs2, skip " \
"the rest of this pass or continue " \
"(a/s/c)?"), "asc");
@@ -253,7 +254,7 @@ static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp)
if (fsck_abort)
return FSCK_CANCELED;
- pass = p->name;
+ pass_name = p->name;
log_notice( _("Starting %s\n"), p->name);
gettimeofday(&timer, NULL);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 8a8ce97c..d619a972 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -29,8 +29,8 @@
#include "metawalk.h"
#include "fs_recovery.h"
-struct special_blocks gfs1_rindex_blks;
-struct gfs2_bmap *bl = NULL;
+static struct special_blocks gfs1_rindex_blks;
+static struct gfs2_bmap *bl = NULL;
struct block_count {
uint64_t indir_count;
@@ -164,7 +164,7 @@ out:
return 0;
}
-struct metawalk_fxns pass1_fxns = {
+static struct metawalk_fxns pass1_fxns = {
.private = NULL,
.check_leaf = p1check_leaf,
.check_metalist = pass1_check_metalist,
@@ -265,7 +265,7 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 0;
}
-struct metawalk_fxns sysdir_fxns = {
+static struct metawalk_fxns sysdir_fxns = {
.private = NULL,
.check_metalist = resuscitate_metalist,
.check_dentry = resuscitate_dentry,
@@ -1088,7 +1088,7 @@ static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
NULL, NULL);
}
-struct metawalk_fxns invalidate_fxns = {
+static struct metawalk_fxns invalidate_fxns = {
.private = NULL,
.check_metalist = invalidate_metadata,
.check_data = invalidate_data,
@@ -1111,7 +1111,7 @@ struct metawalk_fxns invalidate_fxns = {
* Returns: 0 if good range, otherwise != 0
*/
enum b_types { BTYPE_META, BTYPE_LEAF, BTYPE_DATA, BTYPE_IEATTR, BTYPE_EATTR};
-const char *btypes[5] = {
+static const char *btypes[5] = {
"metadata", "leaf", "data", "indirect extended attribute",
"extended attribute" };
@@ -1189,7 +1189,7 @@ static int rangecheck_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
return rangecheck_block(ip, block, NULL, BTYPE_EATTR, private);
}
-struct metawalk_fxns rangecheck_fxns = {
+static struct metawalk_fxns rangecheck_fxns = {
.private = NULL,
.readahead = 1,
.check_metalist = rangecheck_metadata,
@@ -1200,7 +1200,7 @@ struct metawalk_fxns rangecheck_fxns = {
.delete_block = delete_block,
};
-struct metawalk_fxns eattr_undo_fxns = {
+static struct metawalk_fxns eattr_undo_fxns = {
.private = NULL,
.check_eattr_indir = undo_eattr_indir_or_leaf,
.check_eattr_leaf = undo_eattr_indir_or_leaf,
@@ -1319,7 +1319,7 @@ static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
return 0;
}
-struct metawalk_fxns alloc_fxns = {
+static struct metawalk_fxns alloc_fxns = {
.private = NULL,
.check_leaf = alloc_leaf,
.check_metalist = alloc_metalist,
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 98a0a4b8..6592edaf 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -21,9 +21,9 @@
#define MAX_FILENAME 256
-struct metawalk_fxns pass2_fxns;
+static struct metawalk_fxns pass2_fxns;
-struct metawalk_fxns delete_eattrs = {
+static struct metawalk_fxns delete_eattrs = {
.check_eattr_indir = delete_eattr_indir,
.check_eattr_leaf = delete_eattr_leaf,
.check_eattr_entry = delete_eattr_entry,
@@ -144,7 +144,7 @@ static int check_file_type(uint64_t block, uint8_t de_type, int q,
return *isdir;
}
-struct metawalk_fxns pass2_fxns_delete = {
+static struct metawalk_fxns pass2_fxns_delete = {
.private = NULL,
.check_metalist = delete_metadata,
.check_data = delete_data,
@@ -1262,7 +1262,7 @@ out:
* We don't want it to do the "wrong leaf" thing, or set_parent_dir either.
* We just want a basic sanity check on pointers and lengths.
*/
-struct metawalk_fxns leafck_fxns = {
+static struct metawalk_fxns leafck_fxns = {
.check_leaf_depth = check_leaf_depth,
.check_dentry = basic_check_dentry,
.repair_leaf = pass2_repair_leaf,
@@ -1766,7 +1766,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
return error;
}
-struct metawalk_fxns pass2_fxns = {
+static struct metawalk_fxns pass2_fxns = {
.private = NULL,
.check_leaf_depth = check_leaf_depth,
.check_leaf = NULL,
@@ -1815,7 +1815,7 @@ static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
return 0;
}
-struct metawalk_fxns quota_change_fxns = {
+static struct metawalk_fxns quota_change_fxns = {
.check_metalist = check_metalist_qc,
.check_data = check_data_qc,
};
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 0891e143..6da95726 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -16,7 +16,7 @@
#include "util.h"
#include "afterpass1_common.h"
-struct metawalk_fxns pass4_fxns_delete = {
+static struct metawalk_fxns pass4_fxns_delete = {
.private = NULL,
.check_metalist = delete_metadata,
.check_data = delete_data,
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index da62cc47..6698b29c 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -16,8 +16,8 @@
#include "fsck.h"
#include "fs_recovery.h"
-int rindex_modified = 0;
-struct special_blocks false_rgrps;
+static int rindex_modified = 0;
+static struct special_blocks false_rgrps;
#define BAD_RG_PERCENT_TOLERANCE 11
#define AWAY_FROM_BITMAPS 0x1000
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 437ee0ba..20852b27 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -143,14 +143,14 @@ enum summary_types {
stypes = 7,
};
-char *debugfs;
-int termcols = 80, termlines = 30, done = 0;
-unsigned glocks = 0;
-const char *termtype;
-WINDOW *wind;
-int bufsize = 4 * 1024 * 1024;
-char *glock[MAX_GLOCKS];
-int iterations = 0, show_reservations = 0, iters_done = 0;
+static char *debugfs;
+static int termcols = 80, termlines = 30, done = 0;
+static unsigned glocks = 0;
+static const char *termtype;
+static WINDOW *wind;
+static int bufsize = 4 * 1024 * 1024;
+static char *glock[MAX_GLOCKS];
+static int iterations = 0, show_reservations = 0, iters_done = 0;
struct mount_point {
struct mount_point *next;
char *device;
@@ -158,27 +158,26 @@ struct mount_point {
int fd;
struct gfs2_sbd sb;
};
-struct mount_point *mounts;
-char dlmwlines[MAX_LINES][96]; /* waiters lines */
-char dlmglines[MAX_LINES][97]; /* granted lines */
-char contended_filenames[MAX_FILES][PATH_MAX];
-unsigned long long contended_blocks[MAX_FILES];
-int contended_count = 0;
-int line = 0;
-const char *prog_name;
-char dlm_dirtbl_size[32], dlm_rsbtbl_size[32], dlm_lkbtbl_size[32];
-int bsize = 0;
-char print_dlm_grants = 1;
-char *gbuf = NULL; /* glocks buffer */
-char *gpos = NULL;
-char *gnextpos = NULL;
-int gmaxpos = 0;
-
-char *dbuf = NULL; /* dlm locks buffer */
-char *dpos = NULL;
-char *dnextpos = NULL;
-int dmaxpos = 0;
-char hostname[256];
+static struct mount_point *mounts;
+static char dlmwlines[MAX_LINES][96]; /* waiters lines */
+static char dlmglines[MAX_LINES][97]; /* granted lines */
+static char contended_filenames[MAX_FILES][PATH_MAX];
+static unsigned long long contended_blocks[MAX_FILES];
+static int contended_count = 0;
+static int line = 0;
+static const char *prog_name;
+static char dlm_dirtbl_size[32], dlm_rsbtbl_size[32], dlm_lkbtbl_size[32];
+static int bsize = 0;
+static char print_dlm_grants = 1;
+static char *gbuf = NULL; /* glocks buffer */
+static char *gpos = NULL;
+static char *gnextpos = NULL;
+static int gmaxpos = 0;
+static char *dbuf = NULL; /* dlm locks buffer */
+static char *dpos = NULL;
+static char *dnextpos = NULL;
+static int dmaxpos = 0;
+static char hostname[256];
/*
* init_colors
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index bca7b9d1..da82d462 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -160,7 +160,7 @@ static void opts_init(struct mkfs_opts *opts)
opts->format = GFS2_FORMAT_FS;
}
-struct lgfs2_inum *mkfs_journals = NULL;
+static struct lgfs2_inum *mkfs_journals = NULL;
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
diff --git a/gfs2/tune/main.c b/gfs2/tune/main.c
index d5998071..fe137803 100644
--- a/gfs2/tune/main.c
+++ b/gfs2/tune/main.c
@@ -16,9 +16,8 @@
#include <unistd.h>
#include "tunegfs2.h"
-struct tunegfs2 tunegfs2_struct;
-struct tunegfs2 *tfs = &tunegfs2_struct;
-
+static struct tunegfs2 tunegfs2_struct;
+static struct tunegfs2 *tfs = &tunegfs2_struct;
static void parse_mount_options(char *arg)
{
diff --git a/tests/nukerg.c b/tests/nukerg.c
index 399f7373..74b65abb 100644
--- a/tests/nukerg.c
+++ b/tests/nukerg.c
@@ -10,7 +10,7 @@
#include <libgfs2.h>
-const char *prog_name = "nukerg";
+static const char *prog_name = "nukerg";
static void usage(void)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 33/39: libgfs2: Remove gfs_jindex_in
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 7622490f8230856969ee0a3ca5ca3d4da94fa5fc
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 11 12:50:50 2021 +0100
libgfs2: Remove gfs_jindex_in
Also fix some endianness tagging in gfs1.c so that it's now
sparse-clean.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 14 +++++++-------
gfs2/edit/hexedit.h | 1 -
gfs2/edit/journal.c | 7 +++----
gfs2/edit/savemeta.c | 8 ++++----
gfs2/fsck/fs_recovery.c | 7 ++++---
gfs2/fsck/initialize.c | 16 ++++++++--------
gfs2/libgfs2/gfs1.c | 19 +++----------------
gfs2/libgfs2/libgfs2.h | 1 -
8 files changed, 29 insertions(+), 44 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 975a514c..92dbb415 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -424,15 +424,15 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
static void gfs_jindex_print(struct gfs_jindex *ji)
{
- pv(ji, ji_addr, "%"PRIu64, "0x%"PRIx64);
- pv(ji, ji_nsegment, "%"PRIu32, "0x%"PRIx32);
- pv(ji, ji_pad, "%"PRIu32, "0x%"PRIx32);
+ print_it(" ji_addr", "%"PRIu64, "0x%"PRIx64, be64_to_cpu(ji->ji_addr));
+ print_it(" ji_nsegment", "%"PRIu32, "0x%"PRIx32, be32_to_cpu(ji->ji_nsegment));
+ print_it(" ji_pad", "%"PRIu32, "0x%"PRIx32, be32_to_cpu(ji->ji_pad));
}
static int print_gfs_jindex(struct gfs2_inode *dij)
{
int error, start_line;
- struct gfs_jindex ji;
+ struct gfs_jindex *ji;
char jbuf[sizeof(struct gfs_jindex)];
start_line = line;
@@ -444,7 +444,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
error = gfs2_readi(dij, (void *)&jbuf,
print_entry_ndx*sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
- gfs_jindex_in(&ji, jbuf);
+ ji = (struct gfs_jindex *)jbuf;
if (!error) /* end of file */
break;
if (!termlines ||
@@ -454,13 +454,13 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
if (edit_row[dmode] == print_entry_ndx) {
COLORS_HIGHLIGHT;
strcpy(efield, "ji_addr");
- sprintf(estring, "%"PRIx64, ji.ji_addr);
+ sprintf(estring, "%"PRIx64, be64_to_cpu(ji->ji_addr));
}
print_gfs2("Journal #%d", print_entry_ndx);
eol(0);
if (edit_row[dmode] == print_entry_ndx)
COLORS_NORMAL;
- gfs_jindex_print(&ji);
+ gfs_jindex_print(ji);
last_entry_onscreen[dmode] = print_entry_ndx;
}
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index dd509085..adbeb742 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -225,7 +225,6 @@ extern int block_is_statfs_file(uint64_t blk);
extern int block_is_quota_file(uint64_t blk);
extern int block_is_per_node(uint64_t blk);
extern int display_block_type(char *buf, uint64_t addr, int from_restore);
-extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void gfs_log_header_print(void *lhp);
extern void savemeta(char *out_fn, int saveoption, int gziplevel);
extern void restoremeta(const char *in_fn, const char *out_device,
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 95fa7c23..1baba02f 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -58,7 +58,6 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (sbd.gfs1) {
struct gfs2_inode *jiinode;
- struct gfs_jindex ji;
jiinode = lgfs2_inode_get(&sbd, jindex_bh);
if (jiinode == NULL)
@@ -67,9 +66,9 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
journal_num * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
if (amtread) {
- gfs_jindex_in(&ji, jbuf);
- jblock = ji.ji_addr;
- *j_size = (uint64_t)ji.ji_nsegment * 0x10;
+ struct gfs_jindex *ji = (struct gfs_jindex *)jbuf;
+ jblock = be64_to_cpu(ji->ji_addr);
+ *j_size = (uint64_t)be32_to_cpu(ji->ji_nsegment) * 0x10;
}
inode_put(&jiinode);
} else {
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4beff2ca..a99930c2 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -943,7 +943,7 @@ static void get_journal_inode_blocks(void)
struct gfs2_inode *j_inode = NULL;
if (sbd.gfs1) {
- struct gfs_jindex ji;
+ struct gfs_jindex *ji;
char jbuf[sizeof(struct gfs_jindex)];
j_inode = lgfs2_gfs_inode_read(&sbd, sbd.sd_jindex_di.in_addr);
@@ -957,9 +957,9 @@ static void get_journal_inode_blocks(void)
inode_put(&j_inode);
if (!amt)
break;
- gfs_jindex_in(&ji, jbuf);
- jblock = ji.ji_addr;
- gfs1_journal_size = (uint64_t)ji.ji_nsegment * 16;
+ ji = (struct gfs_jindex *)jbuf;
+ jblock = be64_to_cpu(ji->ji_addr);
+ gfs1_journal_size = (uint64_t)be32_to_cpu(ji->ji_nsegment) * 16;
} else {
if (journal + 3 > indirect->ii[0].dirents)
break;
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index bbfd7783..e6744dc2 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -752,7 +752,6 @@ int ji_update(struct gfs2_sbd *sdp)
char journal_name[JOURNAL_NAME_SIZE];
int i, error;
char buf[sizeof(struct gfs_jindex)];
- struct gfs_jindex ji;
if (!ip) {
log_crit(_("Journal index inode not found.\n"));
@@ -778,6 +777,8 @@ int ji_update(struct gfs2_sbd *sdp)
memset(journal_name, 0, sizeof(*journal_name));
for (i = 0; i < sdp->md.journals; i++) {
if (sdp->gfs1) {
+ struct gfs_jindex *ji;
+
error = gfs2_readi(ip,
buf, i * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
@@ -788,8 +789,8 @@ int ji_update(struct gfs2_sbd *sdp)
" journal index file.\n"));
return -1;
}
- gfs_jindex_in(&ji, buf);
- sdp->md.journal[i] = lgfs2_inode_read(sdp, ji.ji_addr);
+ ji = (struct gfs_jindex *)buf;
+ sdp->md.journal[i] = lgfs2_inode_read(sdp, be64_to_cpu(ji->ji_addr));
if (sdp->md.journal[i] == NULL)
return -1;
} else {
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 0869a43e..039a0fd7 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1468,7 +1468,7 @@ static int reset_journal_seg_size(struct gfs2_sbd *sdp, unsigned int jsize, unsi
static int correct_journal_seg_size(struct gfs2_sbd *sdp)
{
int count;
- struct gfs_jindex ji_0, ji_1;
+ struct gfs_jindex *ji_0, *ji_1;
char buf[sizeof(struct gfs_jindex)];
unsigned int jsize = GFS2_DEFAULT_JSIZE * 1024 * 1024;
@@ -1478,7 +1478,7 @@ static int correct_journal_seg_size(struct gfs2_sbd *sdp)
"Aborting\n"), count);
return -1;
}
- gfs_jindex_in(&ji_0, buf);
+ ji_0 = (struct gfs_jindex *)buf;
if (sdp->md.journals == 1) {
if (sdp->sd_seg_size == 0) {
@@ -1505,11 +1505,11 @@ static int correct_journal_seg_size(struct gfs2_sbd *sdp)
"Aborting\n"), count);
return -1;
}
- gfs_jindex_in(&ji_1, buf);
+ ji_1 = (struct gfs_jindex *)buf;
- jsize = (ji_1.ji_addr - ji_0.ji_addr) * sdp->sd_bsize;
+ jsize = (be64_to_cpu(ji_1->ji_addr) - be64_to_cpu(ji_0->ji_addr)) * sdp->sd_bsize;
out:
- return reset_journal_seg_size(sdp, jsize, ji_0.ji_nsegment);
+ return reset_journal_seg_size(sdp, jsize, be32_to_cpu(ji_0->ji_nsegment));
}
/*
@@ -1521,7 +1521,7 @@ out:
static int reconstruct_journals(struct gfs2_sbd *sdp)
{
int i, count;
- struct gfs_jindex ji;
+ struct gfs_jindex *ji;
char buf[sizeof(struct gfs_jindex)];
/* Ensure that sb_seg_size is valid */
@@ -1537,10 +1537,10 @@ static int reconstruct_journals(struct gfs2_sbd *sdp)
sizeof(struct gfs_jindex));
if (count != sizeof(struct gfs_jindex))
return 0;
- gfs_jindex_in(&ji, buf);
+ ji = (struct gfs_jindex *)buf;
if ((i % 2) == 0)
log_err(".");
- if (reconstruct_single_journal(sdp, i, ji.ji_nsegment))
+ if (reconstruct_single_journal(sdp, i, be32_to_cpu(ji->ji_nsegment)))
return -1;
}
log_err(_("\nJournals cleared.\n"));
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index feb8d22a..272f5572 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -22,13 +22,13 @@ static __inline__ int fs_is_jdata(struct gfs2_inode *ip)
return ip->i_flags & GFS2_DIF_JDATA;
}
-static __inline__ uint64_t *
+static __inline__ __be64 *
gfs1_metapointer(char *buf, unsigned int height, struct metapath *mp)
{
unsigned int head_size = (height > 0) ?
sizeof(struct gfs_indirect) : sizeof(struct gfs_dinode);
- return ((uint64_t *)(buf + head_size)) + mp->mp_list[height];
+ return ((__be64 *)(buf + head_size)) + mp->mp_list[height];
}
int is_gfs_dir(struct gfs2_inode *ip)
@@ -42,7 +42,7 @@ void gfs1_lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
int create, int *new, uint64_t *block)
{
- uint64_t *ptr = gfs1_metapointer(bh->b_data, height, mp);
+ __be64 *ptr = gfs1_metapointer(bh->b_data, height, mp);
if (*ptr) {
*block = be64_to_cpu(*ptr);
@@ -307,19 +307,6 @@ struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
return ip;
}
-/* ------------------------------------------------------------------------ */
-/* gfs_jindex_in - read in a gfs1 jindex structure. */
-/* ------------------------------------------------------------------------ */
-void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
-{
- struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
-
- jindex->ji_addr = be64_to_cpu(str->ji_addr);
- jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
- jindex->ji_pad = be32_to_cpu(str->ji_pad);
- memcpy(jindex->ji_reserved, str->ji_reserved, 64);
-}
-
void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf)
{
struct gfs_rgrp *r = buf;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e3afa464..c8ec05aa 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -736,7 +736,6 @@ extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
unsigned int size);
extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf);
extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
-extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_gfs_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 32/39: libgfs2: Fix endianness tagging for
gfs2_bit_search
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit eaa1411c07628b7e50e7b06d60aa2ecf34582714
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 18:17:07 2021 +0100
libgfs2: Fix endianness tagging for gfs2_bit_search
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_bits.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index 72d2b006..8399e486 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -38,7 +38,7 @@
* single test (on 64 bit arches).
*/
-static inline uint64_t gfs2_bit_search(const unsigned long long *ptr,
+static inline uint64_t gfs2_bit_search(const __le64 *ptr,
unsigned long long mask,
uint8_t state)
{
@@ -67,13 +67,12 @@ static inline uint64_t gfs2_bit_search(const unsigned long long *ptr,
unsigned long gfs2_bitfit(const unsigned char *buf, const unsigned int len,
unsigned long goal, unsigned char state)
{
- unsigned long spoint = (goal << 1) & ((8 * sizeof(unsigned long long)) - 1);
- const unsigned long long *ptr = ((unsigned long long *)buf) + (goal >> 5);
- const unsigned long long *end = (unsigned long long *)
- (buf + ALIGN(len, sizeof(unsigned long long)));
- unsigned long long tmp;
- unsigned long long mask = 0x5555555555555555ULL;
- unsigned long bit;
+ uint32_t spoint = (goal << 1) & ((8 * sizeof(uint64_t)) - 1);
+ const __le64 *ptr = ((__le64 *)buf) + (goal >> 5);
+ const __le64 *end = (__le64 *) (buf + ALIGN(len, sizeof(uint64_t)));
+ uint64_t tmp;
+ uint64_t mask = 0x5555555555555555ULL;
+ uint32_t bit;
if (state > 3)
return 0;
@@ -87,9 +86,9 @@ unsigned long gfs2_bitfit(const unsigned char *buf, const unsigned int len,
ptr++;
}
/* Mask off any bits which are more than len bytes from the start */
- if (ptr == end && (len & (sizeof(unsigned long long) - 1)))
- tmp &= (((unsigned long long)~0) >>
- (64 - 8 * (len & (sizeof(unsigned long long) - 1))));
+ if (ptr == end && (len & (sizeof(uint64_t) - 1)))
+ tmp &= (((uint64_t)~0) >>
+ (64 - 8 * (len & (sizeof(uint64_t) - 1))));
/* Didn't find anything, so return */
if (tmp == 0)
return BFITNOENT;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months
[gfs2-utils] 31/39: gfs2l: Sparse fixes
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 8d12a3786a9814b3560d0238e869a45e3cf8fbef
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 18:05:49 2021 +0100
gfs2l: Sparse fixes
Remove a VLA and fix the endianness tagging of some casts.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 15 +++++++++++----
gfs2/libgfs2/lang.c | 6 +++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 15dcd25d..6fc6cd37 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -28,10 +28,16 @@ static int metastrcmp(const void *a, const void *b)
return strcmp(m1->name, m2->name);
}
-static void print_structs(void)
+static int print_structs(void)
{
- const struct lgfs2_metadata *mlist[lgfs2_metadata_size];
+ const struct lgfs2_metadata **mlist;
int i;
+
+ mlist = calloc(lgfs2_metadata_size, sizeof(struct lgfs2_metadata *));
+ if (mlist == NULL) {
+ perror("Failed to create metadata type array");
+ return 1;
+ }
for (i = 0; i < lgfs2_metadata_size; i++)
mlist[i] = &lgfs2_metadata[i];
@@ -39,6 +45,8 @@ static void print_structs(void)
for (i = 0; i < lgfs2_metadata_size; i++)
if (mlist[i]->mh_type != GFS2_METATYPE_NONE)
printf("%s\n", mlist[i]->name);
+ free(mlist);
+ return 0;
}
static void print_fields(const char *name)
@@ -69,8 +77,7 @@ static int getopts(int argc, char *argv[], struct cmdopts *opts)
}
break;
case 'T':
- print_structs();
- exit(0);
+ exit(print_structs());
case 'F':
print_fields(optarg);
exit(0);
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 740d1a7b..dd46cd21 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -327,13 +327,13 @@ static int field_print(char *buf, uint64_t addr, const struct lgfs2_metadata *mt
printf("%"PRIu8"\n", *(uint8_t *)fieldp);
break;
case 2:
- printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t *)fieldp));
+ printf("%"PRIu16"\n", be16_to_cpu(*(__be16 *)fieldp));
break;
case 4:
- printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t *)fieldp));
+ printf("%"PRIu32"\n", be32_to_cpu(*(__be32 *)fieldp));
break;
case 8:
- printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t *)fieldp));
+ printf("%"PRIu64"\n", be64_to_cpu(*(__be64 *)fieldp));
break;
default:
// "Reserved" field so just print 0
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 7 months