There are tons of functions which can be static, make them so.
Fixes many sparse warnings about this.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
extern int platform_check_ismounted(char *, char *, struct stat *, int);
-int logfd;
-char *logfile_name;
-FILE *logerr;
-char LOGFILE_NAME[] = "/var/tmp/xfs_copy.log.XXXXXX";
+static char *logfile_name;
+static FILE *logerr;
+static char LOGFILE_NAME[] = "/var/tmp/xfs_copy.log.XXXXXX";
-char *source_name;
-int source_fd;
+static char *source_name;
+static int source_fd;
-unsigned int source_blocksize; /* source filesystem blocksize */
-unsigned int source_sectorsize; /* source disk sectorsize */
+static unsigned int source_blocksize; /* source filesystem blocksize */
+static unsigned int source_sectorsize; /* source disk sectorsize */
-xfs_agblock_t first_agbno;
+static xfs_agblock_t first_agbno;
-uint64_t barcount[11];
+static uint64_t barcount[11];
-unsigned int num_targets;
-target_control *target;
+static unsigned int num_targets;
+static target_control *target;
-wbuf w_buf;
-wbuf btree_buf;
+static wbuf w_buf;
+static wbuf btree_buf;
-unsigned int kids;
+static unsigned int kids;
-thread_control glob_masks;
-thread_args *targ;
+static thread_control glob_masks;
+static thread_args *targ;
-pthread_mutex_t mainwait;
+static pthread_mutex_t mainwait;
#define ACTIVE 1
#define INACTIVE 2
#define PRE 0x08 /* append strerror string */
#define LAST 0x10 /* final message we print */
-void
+static void
signal_maskfunc(int addset, int newset)
{
sigset_t set;
sigprocmask(newset, &set, NULL);
}
-void
+static void
do_message(int flags, int code, const char *fmt, ...)
{
va_list ap;
return 0;
}
-void
+static void
check_errors(void)
{
int i, first_error = 0;
* don't have to worry about alignment and mins because those
* are taken care of when the buffer's read in
*/
-int
+static int
do_write(
thread_args *args,
wbuf *buf)
return error;
}
-void *
+static void *
begin_reader(void *arg)
{
thread_args *args = arg;
return NULL;
}
-void
+static void
handler(int sig)
{
pid_t pid;
signal(SIGCHLD, handler);
}
-void
+static void
usage(void)
{
fprintf(stderr,
exit(1);
}
-void
+static void
init_bar(uint64_t source_blocks)
{
int i;
barcount[i] = (source_blocks/10)*i;
}
-int
+static int
bump_bar(int tenths, uint64_t numblocks)
{
static char *bar[11] = {
static xfs_off_t source_position = -1;
-wbuf *
+static wbuf *
wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id)
{
ASSERT(data_size % BBSIZE == 0);
return buf;
}
-void
+static void
read_wbuf(int fd, wbuf *buf, xfs_mount_t *mp)
{
int res = 0;
buf->length = res;
}
-void
+static void
read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
xfs_mount_t *mp, int blocksize, int sectorsize)
{
}
-void
+static void
write_wbuf(void)
{
int i;
signal_maskfunc(SIGCHLD, SIG_BLOCK);
}
-void
+static void
sb_update_uuid(
xfs_sb_t *sb, /* Original fs superblock */
ag_header_t *ag_hdr, /* AG hdr to update for this copy */
main(int argc, char **argv)
{
int i, j;
+ int logfd;
int howfar = 0;
int open_flags;
xfs_off_t pos;
return 0;
}
-char *
+static char *
next_log_chunk(char *p, int offset, void *private)
{
wbuf *buf = (wbuf *)private;
/*
* Definition of the possible btree block layouts.
*/
-struct xfs_db_btree {
+static struct xfs_db_btree {
uint32_t magic;
size_t block_len;
size_t key_len;
bit_offset / NBBY, bit_offset % NBBY, modestr[mode]);
}
-int
+static int
blocktrash_f(
int argc,
char **argv)
return 0;
}
-int
+static int
blockuse_f(
int argc,
char **argv)
}
}
-int
+static int
fsmap_f(
int argc,
char **argv)
int blkbb;
int exitcode;
int expert_mode;
-int force;
-struct xfs_mount xmount;
+static int force;
+static struct xfs_mount xmount;
struct xfs_mount *mp;
-struct xlog xlog;
+static struct xlog xlog;
libxfs_init_t x;
xfs_agnumber_t cur_agno = NULLAGNUMBER;
exit(1);
}
-void
+static void
init(
int argc,
char **argv)
# include <histedit.h>
#endif
-int inputstacksize;
-FILE **inputstack;
-FILE *curinput;
+static int inputstacksize;
+static FILE **inputstack;
+static FILE *curinput;
static void popfile(void);
static int source_f(int argc, char **argv);
ioc->dirino, ioc->typ == NULL ? _("none") : ioc->typ->name);
}
-void
+static void
print_ring(void)
{
int i;
i, res->tr_logres, res->tr_logcount, res->tr_logflags);
}
-int
+static int
logres_f(
int argc,
char **argv)
#include <sys/stat.h>
#include <ftw.h>
-unsigned long long
+static unsigned long long
cvtnum(char *s)
{
unsigned long long i;
#define FBLOCKS(n) ((n)/blocksize)
-unsigned long long dirsize=0; /* bytes */
-unsigned long long logsize=LOGSIZE*BLOCKSIZE; /* bytes */
-unsigned long long fullblocks=0; /* FS blocks */
-unsigned long long isize=0; /* inodes bytes */
-unsigned long long blocksize=BLOCKSIZE;
-unsigned long long nslinks=0; /* number of symbolic links */
-unsigned long long nfiles=0; /* number of regular files */
-unsigned long long ndirs=0; /* number of directories */
-unsigned long long nspecial=0; /* number of special files */
-unsigned long long verbose=0; /* verbose mode TRUE/FALSE */
-
-int __debug = 0;
-int ilog = 0;
-int elog = 0;
-
-void
+static unsigned long long dirsize=0; /* bytes */
+static unsigned long long logsize=LOGSIZE*BLOCKSIZE; /* bytes */
+static unsigned long long fullblocks=0; /* FS blocks */
+static unsigned long long isize=0; /* inodes bytes */
+static unsigned long long blocksize=BLOCKSIZE;
+static unsigned long long nslinks=0; /* number of symbolic links */
+static unsigned long long nfiles=0; /* number of regular files */
+static unsigned long long ndirs=0; /* number of directories */
+static unsigned long long nspecial=0; /* number of special files */
+static unsigned long long verbose=0; /* verbose mode TRUE/FALSE */
+
+static int __debug = 0;
+static int ilog = 0;
+static int elog = 0;
+
+static void
usage(char *progname)
{
fprintf(stderr,
char *progname;
-int vflag;
-int gflag;
+static int vflag;
+static int gflag;
static int Mflag;
/* static int nflag; */
-int dflag = 0;
+static int dflag = 0;
/* static int sflag; */
-int argv_blksz_dio;
+static int argv_blksz_dio;
extern int max_ext_size;
static int npasses = 10;
static int startpass = 0;
-struct getbmap *outmap = NULL;
-int outmap_size = 0;
-int RealUid;
-int tmp_agi;
+static struct getbmap *outmap = NULL;
+static int outmap_size = 0;
+static int RealUid;
+static int tmp_agi;
static int64_t minimumfree = 2048;
#define MNTTYPE_XFS "xfs"
static void tmp_close(char *mnt);
int xfs_getgeom(int , xfs_fsop_geom_v1_t * );
-xfs_fsop_geom_v1_t fsgeom; /* geometry of active mounted system */
+static xfs_fsop_geom_v1_t fsgeom; /* geometry of active mounted system */
#define NMOUNT 64
static int numfs;
int npass;
} fsdesc_t;
-fsdesc_t *fs, *fsbase, *fsend;
-int fsbufsize = 10; /* A starting value */
-int nfrags = 0; /* Debug option: Coerse into specific number
+static fsdesc_t *fs, *fsbase, *fsend;
+static int fsbufsize = 10; /* A starting value */
+static int nfrags = 0; /* Debug option: Coerse into specific number
* of extents */
-int openopts = O_CREAT|O_EXCL|O_RDWR|O_DIRECT;
+static int openopts = O_CREAT|O_EXCL|O_RDWR|O_DIRECT;
-int
+static int
xfs_fsgeometry(int fd, xfs_fsop_geom_v1_t *geom)
{
return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, geom);
}
-int
+static int
xfs_bulkstat_single(int fd, xfs_ino_t *lastip, xfs_bstat_t *ubuffer)
{
xfs_fsop_bulkreq_t bulkreq;
return ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bulkreq);
}
-int
+static int
xfs_bulkstat(int fd, xfs_ino_t *lastip, int icount,
xfs_bstat_t *ubuffer, __s32 *ocount)
{
return ioctl(fd, XFS_IOC_FSBULKSTAT, &bulkreq);
}
-int
+static int
xfs_swapext(int fd, xfs_swapext_t *sx)
{
return ioctl(fd, XFS_IOC_SWAPEXT, sx);
}
-int
+static int
xfs_fscounts(int fd, xfs_fsop_counts_t *counts)
{
return ioctl(fd, XFS_IOC_FSCOUNTS, counts);
}
-void
+static void
aborter(int unused)
{
fsrall_cleanup(1);
/*
* Read the block map and return the number of extents.
*/
-int
+static int
getnextents(int fd)
{
int nextents;
"\n"));
}
-int
+static int
bmap_f(
int argc,
char **argv)
}
}
-int
+static int
fiemap_f(
int argc,
char **argv)
static cmdinfo_t freeze_cmd;
static cmdinfo_t thaw_cmd;
-int
+static int
freeze_f(
int argc,
char **argv)
return 0;
}
-int
+static int
thaw_f(
int argc,
char **argv)
NFLG+1, NFLG+1, FLG_ESW);
}
-int
+static int
fsmap_f(
int argc,
char **argv)
static cmdinfo_t imap_cmd;
-int
+static int
imap_f(int argc, char **argv)
{
int count;
char *progname;
int exitcode;
int expert;
-int idlethread;
+static int idlethread;
size_t pagesize;
struct timeval stopwatch;
-void
+static void
usage(void)
{
fprintf(stderr,
return 1;
}
-void
+static void
init(
int argc,
char **argv)
* are not reference counted. Spawning an idle thread can help detecting file
* struct reference leaks.
*/
-void *
+static void *
idle_loop(void *arg)
{
for (;;)
return NULL;
}
-void
+static void
start_idle_thread(void)
{
pthread_t t;
"\n"));
}
-int
+static int
madvise_f(
int argc,
char **argv)
static cmdinfo_t mincore_cmd;
-int
+static int
mincore_f(
int argc,
char **argv)
"\n"));
}
-int
+static int
msync_f(
int argc,
char **argv)
"\n"));
}
-int
+static int
mread_f(
int argc,
char **argv)
return 0;
}
-int
+static int
munmap_f(
int argc,
char **argv)
"\n"));
}
-int
+static int
mwrite_f(
int argc,
char **argv)
"\n"));
}
-int
+static int
mremap_f(
int argc,
char **argv)
return retval;
}
-int
+static int
parent_f(int argc, char **argv)
{
int c;
static struct cmdinfo readdir_cmd;
-const char *d_type_str(unsigned int type)
+static const char *d_type_str(unsigned int type)
{
const char *str;
#define DATA 0
#define HOLE 1
-struct seekinfo {
+static struct seekinfo {
char *name; /* display item name */
int seektype; /* data or hole */
int mask; /* compared for print and looping */
};
/* print item type and offset. catch special cases of eof and error */
-void
+static void
seek_output(
int startflag,
char *type,
return 0;
}
-void print_file_info(void)
+static void
+print_file_info(void)
{
printf(_("fd.path = \"%s\"\n"), file->name);
printf(_("fd.flags = %s,%s,%s%s%s%s%s\n"),
file->flags & IO_TMPFILE ? _(",tmpfile") : "");
}
-void print_xfs_info(int verbose)
+static void
+print_xfs_info(int verbose)
{
struct dioattr dio;
struct fsxattr fsx, fsxa;
* - output style for flags (and all else?) (chars vs. hex?)
* - output - mask out incidental flag or not?
*/
-int
+static int
statx_f(
int argc,
char **argv)
bool iterate;
};
-static int ncmdline;
-struct cmdline *cmdline;
+static int ncmdline;
+static struct cmdline *cmdline;
static int
compare(const void *a, const void *b)
return cache;
}
-void
+static void
cache_expand(
struct cache * cache)
{
* dev_map - map open devices to fd.
*/
#define MAX_DEVS 10 /* arbitary maximum */
-int nextfakedev = -1; /* device number to give to next fake device */
+static int nextfakedev = -1; /* device number to give to next fake device */
static struct dev_to_fd {
dev_t dev;
int fd;
return CACHE_MISS;
}
-void
+static void
libxfs_bprint(xfs_buf_t *bp)
{
fprintf(stderr, "Buffer %p blkno=%llu bytes=%u flags=0x%x count=%u\n",
bp->b_flags |= LIBXFS_B_DISCONTIG;
}
-xfs_buf_t *
+static xfs_buf_t *
__libxfs_getbufr(int blen)
{
xfs_buf_t *bp;
return bp;
}
-xfs_buf_t *
+static xfs_buf_t *
libxfs_getbufr_map(struct xfs_buftarg *btp, xfs_daddr_t blkno, int bblen,
struct xfs_buf_map *map, int nmaps)
{
* This was once shared with the kernel, but has diverged to the point
* where it's no longer worth the hassle of maintaining common code.
*/
-int
+static int
libxfs_ialloc(
xfs_trans_t *tp,
xfs_inode_t *pip,
return 0;
}
-void
+static void
libxfs_iprint(
xfs_inode_t *ip)
{
* repair can validate it against the state of the log.
*/
xfs_lsn_t libxfs_max_lsn = 0;
-pthread_mutex_t libxfs_max_lsn_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t libxfs_max_lsn_lock = PTHREAD_MUTEX_INITIALIZER;
bool
xfs_log_check_lsn(
int si_skip;
} xlog_split_item_t;
-xlog_split_item_t *split_list = NULL;
+static xlog_split_item_t *split_list = NULL;
void
print_xlog_op_line(void)
"--------------------------------------\n");
} /* print_xlog_op_line */
-void
+static void
print_xlog_xhdr_line(void)
{
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
* Given a pointer to a data segment, print out the data as if it were
* a log operation header.
*/
-void
+static void
xlog_print_op_header(xlog_op_header_t *op_head,
int i,
char **ptr)
} /* xlog_print_op_header */
-void
+static void
xlog_print_add_to_trans(xlog_tid_t tid,
int skip)
{
} /* xlog_print_add_to_trans */
-int
+static int
xlog_print_find_tid(xlog_tid_t tid, uint was_cont)
{
xlog_split_item_t *listp = split_list;
return 1;
} /* xlog_print_find_tid */
-int
+static int
xlog_print_trans_header(char **ptr, int len)
{
xfs_trans_header_t *h;
} /* xlog_print_trans_header */
-int
+static int
xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
{
xfs_buf_log_format_t *f;
} /* xlog_print_trans_buffer */
-int
+static int
xlog_print_trans_qoff(char **ptr, uint len)
{
xfs_qoff_logformat_t *f;
} /* xlog_print_trans_qoff */
-void
+static void
xlog_print_trans_inode_core(
struct xfs_log_dinode *ip)
{
}
}
-void
+static void
xlog_print_dir2_sf(
struct xlog *log,
xfs_dir2_sf_hdr_t *sfp,
}
}
-int
+static int
xlog_print_trans_inode(
struct xlog *log,
char **ptr,
} /* xlog_print_trans_inode */
-int
+static int
xlog_print_trans_dquot(char **ptr, int len, int *i, int num_ops)
{
xfs_dq_logformat_t *f;
} /* xlog_print_lseek */
-void
+static void
print_lsn(char *string,
__be64 *lsn)
{
}
-int
+static int
xlog_print_record(
struct xlog *log,
int fd,
} /* xlog_print_record */
-int
+static int
xlog_print_rec_head(xlog_rec_header_t *head, int *len, int bad_hdr_warn)
{
int i;
return(be32_to_cpu(head->h_num_logops));
} /* xlog_print_rec_head */
-void
+static void
xlog_print_rec_xhead(xlog_rec_ext_header_t *head, int coverage)
{
int i;
xlog_exit("Bad log record header");
} /* print_xlog_bad_header */
-void
+static void
print_xlog_bad_data(xfs_daddr_t blkno)
{
print_stars();
}
}
-void
+static void
xlog_recover_print_item(
xlog_recover_item_t *item)
{
int print_no_data;
int print_no_print;
int print_exit = 1; /* -e is now default. specify -c to override */
-int print_operation = OP_PRINT;
+static int print_operation = OP_PRINT;
-void
+static void
usage(void)
{
fprintf(stderr, _("Usage: %s [options...] <device>\n\n\
exit(1);
}
-int
+static int
logstat(xfs_mount_t *mp)
{
int fd;
#include "xfs_metadump.h"
char *progname;
-int show_progress = 0;
-int show_info = 0;
-int progress_since_warning = 0;
+static int show_progress = 0;
+static int show_info = 0;
+static int progress_since_warning = 0;
static void
fatal(const char *msg, ...)
* XXX: The configured block and sector sizes are defined as global variables so
* that they don't need to be passed to getnum/cvtnum().
*/
-unsigned int blocksize;
-unsigned int sectorsize;
+static unsigned int blocksize;
+static unsigned int sectorsize;
/*
* Enums for each CLI parameter type are declared first so we can calculate the
* about tables that haven't yet been defined. Work around this ordering
* issue with extern definitions here.
*/
-extern struct opt_params sopts;
+static struct opt_params sopts;
-struct opt_params bopts = {
+static struct opt_params bopts = {
.name = 'b',
.subopts = {
[B_SIZE] = "size",
},
};
-struct opt_params dopts = {
+static struct opt_params dopts = {
.name = 'd',
.subopts = {
[D_AGCOUNT] = "agcount",
};
-struct opt_params iopts = {
+static struct opt_params iopts = {
.name = 'i',
.subopts = {
[I_ALIGN] = "align",
},
};
-struct opt_params lopts = {
+static struct opt_params lopts = {
.name = 'l',
.subopts = {
[L_AGNUM] = "agnum",
},
};
-struct opt_params nopts = {
+static struct opt_params nopts = {
.name = 'n',
.subopts = {
[N_SIZE] = "size",
},
};
-struct opt_params ropts = {
+static struct opt_params ropts = {
.name = 'r',
.subopts = {
[R_EXTSIZE] = "extsize",
},
};
-struct opt_params sopts = {
+static struct opt_params sopts = {
.name = 's',
.subopts = {
[S_SIZE] = "size",
},
};
-struct opt_params mopts = {
+static struct opt_params mopts = {
.name = 'm',
.subopts = {
[M_CRC] = "crc",
return 0;
}
-struct subopts {
+static struct subopts {
char opt;
struct opt_params *opts;
int (*parser)(struct opt_params *opts,
}
}
-void
+static void
validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
{
if (logblocks < min_logblocks) {
return value;
}
-void *
+static void *
btree_uncached_lookup(
struct btree_root *root,
unsigned long key)
* reused. the duplicate and bno/bcnt extent trees for each AG
* are recycled after they're no longer needed to save memory
*/
-void
+static void
release_extent_tree(avltree_desc_t *tree)
{
extent_tree_node_t *ext;
return((uintptr_t) ((extent_tree_node_t *)node)->ex_blockcount);
}
-avlops_t avl_extent_bcnt_tree_ops = {
+static avlops_t avl_extent_bcnt_tree_ops = {
avl_ext_bcnt_start,
avl_ext_bcnt_end
};
-avlops_t avl_extent_tree_ops = {
+static avlops_t avl_extent_tree_ops = {
avl_ext_start,
avl_ext_end
};
((rt_extent_tree_node_t *) node)->rt_blockcount);
}
-avl64ops_t avl64_extent_tree_ops = {
+static avl64ops_t avl64_extent_tree_ops = {
avl64_rt_ext_start,
avl64_ext_end
};
extent_bno_ptrs = NULL;
}
-int
+static int
count_extents(xfs_agnumber_t agno, avltree_desc_t *tree, int whichtree)
{
extent_tree_node_t *node;
return(ino_rec);
}
-void
+static void
print_inode_list_int(xfs_agnumber_t agno, int uncertain)
{
ino_tree_node_t *ino_rec;
XFS_INODES_PER_CHUNK));
}
-avlops_t avl_ino_tree_ops = {
+static avlops_t avl_ino_tree_ops = {
avl_ino_start,
avl_ino_end
};
do_error(_("xfs_trans_reserve returned %d\n"), err);
}
-void
+static void
mk_rbmino(xfs_mount_t *mp)
{
xfs_trans_t *tp;
&rpt_fmts[FMT1], &rpt_types[TYPE_AG]}
};
-pthread_t report_thread;
+static pthread_t report_thread;
typedef struct msg_block_s {
pthread_mutex_t mutex;
memset(source->sb_fname, 0, 12);
}
-int
+static int
verify_sb_blocksize(xfs_sb_t *sb)
{
/* check to make sure blocksize is legal 2^N, 9 <= N <= 16 */
INOBT,
FINOBT
};
-const char *inobt_names[] = {
+static const char *inobt_names[] = {
"inobt",
"finobt"
};
int rtcp(char *, char *, int);
int xfsrtextsize(char *path);
-int pflag;
+static int pflag;
char *progname;
-void
+static void
usage(void)
{
fprintf(stderr, _("%s [-e extsize] [-p] [-V] source target\n"), progname);
}
/* Save a scrub context for later repairs. */
-bool
+static bool
xfs_scrub_save_repair(
struct scrub_ctx *ctx,
struct xfs_action_list *alist,
char *progname;
int exitcode;
-void
+static void
usage(void)
{
fprintf(stderr,
return 1;
}
-void
+static void
init(
int argc,
char **argv)