Skip to content

Commit

Permalink
Fix declarations of non-global variables
Browse files Browse the repository at this point in the history
This patch inserts the `static` keyword to non-global variables,
which where found by the analysis tool smatch.

Signed-off-by: Tino Reichardt <[email protected]>
  • Loading branch information
mcmilk committed Oct 8, 2022
1 parent 72c99dc commit c5e8d90
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 57 deletions.
7 changes: 4 additions & 3 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ uint8_t dump_opt[256];

typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size);

uint64_t *zopt_metaslab = NULL;
static uint64_t *zopt_metaslab = NULL;
static unsigned zopt_metaslab_args = 0;

typedef struct zopt_object_range {
uint64_t zor_obj_start;
uint64_t zor_obj_end;
uint64_t zor_flags;
} zopt_object_range_t;
zopt_object_range_t *zopt_object_ranges = NULL;

static zopt_object_range_t *zopt_object_ranges = NULL;
static unsigned zopt_object_args = 0;

static int flagbits[256];
Expand All @@ -160,7 +161,7 @@ static int flagbits[256];
#define ZDB_FLAG_PRINT_BLKPTR 0x0040
#define ZDB_FLAG_VERBOSE 0x0080

uint64_t max_inflight_bytes = 256 * 1024 * 1024; /* 256MB */
static uint64_t max_inflight_bytes = 256 * 1024 * 1024; /* 256MB */
static int leaked_objects = 0;
static range_tree_t *mos_refd_objs;

Expand Down
8 changes: 4 additions & 4 deletions cmd/zstream/zstream_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
*/
#define DUMP_GROUPING 4

uint64_t total_stream_len = 0;
FILE *send_stream = 0;
boolean_t do_byteswap = B_FALSE;
boolean_t do_cksum = B_TRUE;
static uint64_t total_stream_len = 0;
static FILE *send_stream = 0;
static boolean_t do_byteswap = B_FALSE;
static boolean_t do_cksum = B_TRUE;

void *
safe_malloc(size_t size)
Expand Down
16 changes: 8 additions & 8 deletions cmd/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,19 @@ ztest_func_t ztest_fletcher;
ztest_func_t ztest_fletcher_incr;
ztest_func_t ztest_verify_dnode_bt;

uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
uint64_t zopt_often = 1ULL * NANOSEC; /* every second */
uint64_t zopt_sometimes = 10ULL * NANOSEC; /* every 10 seconds */
uint64_t zopt_rarely = 60ULL * NANOSEC; /* every 60 seconds */
static uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
static uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
static uint64_t zopt_often = 1ULL * NANOSEC; /* every second */
static uint64_t zopt_sometimes = 10ULL * NANOSEC; /* every 10 seconds */
static uint64_t zopt_rarely = 60ULL * NANOSEC; /* every 60 seconds */

#define ZTI_INIT(func, iters, interval) \
{ .zi_func = (func), \
.zi_iters = (iters), \
.zi_interval = (interval), \
.zi_funcname = # func }

ztest_info_t ztest_info[] = {
static ztest_info_t ztest_info[] = {
ZTI_INIT(ztest_dmu_read_write, 1, &zopt_always),
ZTI_INIT(ztest_dmu_write_parallel, 10, &zopt_always),
ZTI_INIT(ztest_dmu_object_alloc_free, 1, &zopt_always),
Expand Down Expand Up @@ -515,7 +515,7 @@ typedef struct ztest_shared {

static char ztest_dev_template[] = "%s/%s.%llua";
static char ztest_aux_template[] = "%s/%s.%s.%llu";
ztest_shared_t *ztest_shared;
static ztest_shared_t *ztest_shared;

static spa_t *ztest_spa = NULL;
static ztest_ds_t *ztest_ds;
Expand Down Expand Up @@ -2346,7 +2346,7 @@ ztest_replay_setattr(void *arg1, void *arg2, boolean_t byteswap)
return (0);
}

zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = {
static zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = {
NULL, /* 0 no such transaction type */
ztest_replay_create, /* TX_CREATE */
NULL, /* TX_MKDIR */
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/spl/spl-condvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#endif

#define MAX_HRTIMEOUT_SLACK_US 1000
unsigned int spl_schedule_hrtimeout_slack_us = 0;
static unsigned int spl_schedule_hrtimeout_slack_us = 0;

static int
param_set_hrtimeout_slack(const char *buf, zfs_kernel_param_t *kp)
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/spl/spl-err.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* analysis and other such goodies.
* But we would still default to the current default of not to do that.
*/
unsigned int spl_panic_halt;
static unsigned int spl_panic_halt;
/* CSTYLED */
module_param(spl_panic_halt, uint, 0644);
MODULE_PARM_DESC(spl_panic_halt, "Cause kernel panic on assertion failures");
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/spl/spl-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ EXPORT_SYMBOL(p0);
* and use them when in_interrupt() from linux/preempt_mask.h evaluates to
* true.
*/
void __percpu *spl_pseudo_entropy;
static void __percpu *spl_pseudo_entropy;

/*
* spl_rand_next()/spl_rand_jump() are copied from the following CC-0 licensed
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/spl/spl-kmem-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ MODULE_PARM_DESC(spl_kmem_cache_kmem_threads,

struct list_head spl_kmem_cache_list; /* List of caches */
struct rw_semaphore spl_kmem_cache_sem; /* Cache list lock */
taskq_t *spl_kmem_cache_taskq; /* Task queue for aging / reclaim */
static taskq_t *spl_kmem_cache_taskq; /* Task queue for aging / reclaim */

static void spl_cache_shrink(spl_kmem_cache_t *skc, void *obj);

Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/abd_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static abd_stats_t abd_stats = {
{ "scatter_sg_table_retry", KSTAT_DATA_UINT64 },
};

struct {
static struct {
wmsum_t abdstat_struct_size;
wmsum_t abdstat_linear_cnt;
wmsum_t abdstat_linear_data_size;
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zfs_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct zfs_dbgmsg {

static procfs_list_t zfs_dbgmsgs;
static uint_t zfs_dbgmsg_size = 0;
uint_t zfs_dbgmsg_maxsize = 4<<20; /* 4MB */
static uint_t zfs_dbgmsg_maxsize = 4<<20; /* 4MB */

/*
* Internal ZFS debug messages are enabled by default.
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct zvol_state_os {
boolean_t use_blk_mq;
};

taskq_t *zvol_taskq;
static taskq_t *zvol_taskq;
static struct ida zvol_ida;

typedef struct zv_request_stack {
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3360,7 +3360,7 @@ zio_ddt_write(zio_t *zio)
return (zio);
}

ddt_entry_t *freedde; /* for debugging */
static ddt_entry_t *freedde; /* for debugging */

static zio_t *
zio_ddt_free(zio_t *zio)
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zio_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* If nonzero, every 1/X decompression attempts will fail, simulating
* an undetected memory error.
*/
unsigned long zio_decompress_fail_fraction = 0;
static unsigned long zio_decompress_fail_fraction = 0;

/*
* Compression vectors.
Expand Down
10 changes: 5 additions & 5 deletions tests/zfs-tests/cmd/btree_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

#define BUFSIZE 256

int seed = 0;
int stress_timeout = 180;
int contents_frequency = 100;
int tree_limit = 64 * 1024;
boolean_t stress_only = B_FALSE;
static int seed = 0;
static int stress_timeout = 180;
static int contents_frequency = 100;
static int tree_limit = 64 * 1024;
static boolean_t stress_only = B_FALSE;

static void
usage(int exit_value)
Expand Down
18 changes: 9 additions & 9 deletions tests/zfs-tests/cmd/checksum/edonr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
* Test messages from:
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf
*/
const char *test_msg0 = "abc";
const char *test_msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmn"
"lmnomnopnopq";
const char *test_msg2 = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
"jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
static const char *test_msg0 = "abc";
static const char *test_msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklm"
"nlmnomnopnopq";
static const char *test_msg2 = "abcdefghbcdefghicdefghijdefghijkefghijklfgh"
"ijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";

/*
* Test digests computed by hand. There's no formal standard or spec for edonr.
*/
const uint8_t edonr_224_test_digests[][28] = {
static const uint8_t edonr_224_test_digests[][28] = {
{
/* for test_msg0 */
0x56, 0x63, 0xc4, 0x93, 0x95, 0x20, 0xfa, 0xf6,
Expand All @@ -67,7 +67,7 @@ const uint8_t edonr_224_test_digests[][28] = {
/* no test vector for test_msg2 */
};

const uint8_t edonr_256_test_digests[][32] = {
static const uint8_t edonr_256_test_digests[][32] = {
{
/* for test_msg0 */
0x54, 0xd7, 0x8b, 0x13, 0xc7, 0x4e, 0xda, 0x5a,
Expand All @@ -85,7 +85,7 @@ const uint8_t edonr_256_test_digests[][32] = {
/* no test vectorfor test_msg2 */
};

const uint8_t edonr_384_test_digests[][48] = {
static const uint8_t edonr_384_test_digests[][48] = {
{
/* for test_msg0 */
0x0e, 0x7c, 0xd7, 0x85, 0x78, 0x77, 0xe0, 0x89,
Expand All @@ -110,7 +110,7 @@ const uint8_t edonr_384_test_digests[][48] = {
}
};

const uint8_t edonr_512_test_digests[][64] = {
static const uint8_t edonr_512_test_digests[][64] = {
{
/* for test_msg0 */
0x1b, 0x14, 0xdb, 0x15, 0x5f, 0x1d, 0x40, 0x65,
Expand Down
20 changes: 10 additions & 10 deletions tests/zfs-tests/cmd/checksum/sha2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf
*/

const char *test_msg0 = "abc";
const char *test_msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmn"
"lmnomnopnopq";
const char *test_msg2 = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
"jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
static const char *test_msg0 = "abc";
static const char *test_msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklm"
"nlmnomnopnopq";
static const char *test_msg2 = "abcdefghbcdefghicdefghijdefghijkefghijklfgh"
"ijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";

/*
* Test digests from:
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf
*/
const uint8_t sha256_test_digests[][32] = {
static const uint8_t sha256_test_digests[][32] = {
{
/* for test_msg0 */
0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA,
Expand All @@ -72,7 +72,7 @@ const uint8_t sha256_test_digests[][32] = {
/* no test vector for test_msg2 */
};

const uint8_t sha384_test_digests[][48] = {
static const uint8_t sha384_test_digests[][48] = {
{
/* for test_msg0 */
0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B,
Expand All @@ -97,7 +97,7 @@ const uint8_t sha384_test_digests[][48] = {
}
};

const uint8_t sha512_test_digests[][64] = {
static const uint8_t sha512_test_digests[][64] = {
{
/* for test_msg0 */
0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA,
Expand Down Expand Up @@ -126,7 +126,7 @@ const uint8_t sha512_test_digests[][64] = {
}
};

const uint8_t sha512_224_test_digests[][28] = {
static const uint8_t sha512_224_test_digests[][28] = {
{
/* for test_msg0 */
0x46, 0x34, 0x27, 0x0F, 0x70, 0x7B, 0x6A, 0x54,
Expand All @@ -147,7 +147,7 @@ const uint8_t sha512_224_test_digests[][28] = {
}
};

const uint8_t sha512_256_test_digests[][32] = {
static const uint8_t sha512_256_test_digests[][32] = {
{
/* for test_msg0 */
0x53, 0x04, 0x8E, 0x26, 0x81, 0x94, 0x1E, 0xF9,
Expand Down
16 changes: 8 additions & 8 deletions tests/zfs-tests/cmd/checksum/skein_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@
/*
* Test messages from the Skein spec, Appendix C.
*/
const uint8_t test_msg0[] = {
static const uint8_t test_msg0[] = {
0xFF
};

const uint8_t test_msg1[] = {
static const uint8_t test_msg1[] = {
0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8,
0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0,
0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8,
0xE7, 0xE6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1, 0xE0
};

const uint8_t test_msg2[] = {
static const uint8_t test_msg2[] = {
0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8,
0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0,
0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8,
Expand All @@ -66,7 +66,7 @@ const uint8_t test_msg2[] = {
0xC7, 0xC6, 0xC5, 0xC4, 0xC3, 0xC2, 0xC1, 0xC0
};

const uint8_t test_msg3[] = {
static const uint8_t test_msg3[] = {
0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8,
0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0,
0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8,
Expand All @@ -85,7 +85,7 @@ const uint8_t test_msg3[] = {
0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80
};

const uint8_t test_msg4[] = {
static const uint8_t test_msg4[] = {
0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8,
0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0,
0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8,
Expand Down Expand Up @@ -123,7 +123,7 @@ const uint8_t test_msg4[] = {
/*
* Test digests from the Skein spec, Appendix C.
*/
const uint8_t skein_256_test_digests[][32] = {
static const uint8_t skein_256_test_digests[][32] = {
{
/* for test_msg0 */
0x0B, 0x98, 0xDC, 0xD1, 0x98, 0xEA, 0x0E, 0x50,
Expand All @@ -148,7 +148,7 @@ const uint8_t skein_256_test_digests[][32] = {
/* no test digests for test_msg3 and test_msg4 */
};

const uint8_t skein_512_test_digests[][64] = {
static const uint8_t skein_512_test_digests[][64] = {
{
/* for test_msg0 */
0x71, 0xB7, 0xBC, 0xE6, 0xFE, 0x64, 0x52, 0x22,
Expand Down Expand Up @@ -189,7 +189,7 @@ const uint8_t skein_512_test_digests[][64] = {
/* no test digests for test_msg4 */
};

const uint8_t skein_1024_test_digests[][128] = {
static const uint8_t skein_1024_test_digests[][128] = {
{
/* for test_msg0 */
0xE6, 0x2C, 0x05, 0x80, 0x2E, 0xA0, 0x15, 0x24,
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/cmd/mmap_libaio.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <libaio.h>
#include <err.h>

io_context_t io_ctx;
static io_context_t io_ctx;

static void
do_sync_io(struct iocb *iocb)
Expand Down

0 comments on commit c5e8d90

Please sign in to comment.