mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +03:00
Enable -Wwrite-strings
Also, fix leak from ztest_global_vars_to_zdb_args() Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13348
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
|
||||
typedef struct timetest {
|
||||
int type;
|
||||
char *name;
|
||||
const char *name;
|
||||
int (*func)(const char *pfile);
|
||||
} timetest_t;
|
||||
|
||||
@@ -260,7 +260,7 @@ static int
|
||||
do_xattr(const char *pfile)
|
||||
{
|
||||
int ret = 0;
|
||||
char *value = "user.value";
|
||||
const char *value = "user.value";
|
||||
|
||||
if (pfile == NULL) {
|
||||
return (-1);
|
||||
@@ -306,7 +306,7 @@ int
|
||||
main(void)
|
||||
{
|
||||
int i, ret, fd;
|
||||
char *penv[] = {"TESTDIR", "TESTFILE0"};
|
||||
const char *penv[] = {"TESTDIR", "TESTFILE0"};
|
||||
|
||||
(void) atexit(cleanup);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static char dirpath[256];
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *cp1 = "";
|
||||
const char *cp1 = "";
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
int testdd = 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ read_map(const char *filename, nvlist_t **allcfgs)
|
||||
* for freeing the configuration returned.
|
||||
*/
|
||||
static int
|
||||
read_map_key(const char *filename, char *key, nvlist_t **cfg)
|
||||
read_map_key(const char *filename, const char *key, nvlist_t **cfg)
|
||||
{
|
||||
nvlist_t *allcfgs, *foundcfg = NULL;
|
||||
int error;
|
||||
@@ -320,8 +320,8 @@ write_map_key(const char *filename, char *key, draid_map_t *map,
|
||||
}
|
||||
|
||||
static void
|
||||
dump_map(draid_map_t *map, char *key, double worst_ratio, double avg_ratio,
|
||||
int verbose)
|
||||
dump_map(draid_map_t *map, const char *key, double worst_ratio,
|
||||
double avg_ratio, int verbose)
|
||||
{
|
||||
if (verbose == 0) {
|
||||
return;
|
||||
@@ -363,7 +363,7 @@ dump_map(draid_map_t *map, char *key, double worst_ratio, double avg_ratio,
|
||||
}
|
||||
|
||||
static void
|
||||
dump_map_nv(char *key, nvlist_t *cfg, int verbose)
|
||||
dump_map_nv(const char *key, nvlist_t *cfg, int verbose)
|
||||
{
|
||||
draid_map_t map;
|
||||
uint_t c;
|
||||
@@ -385,7 +385,7 @@ dump_map_nv(char *key, nvlist_t *cfg, int verbose)
|
||||
* Print a summary of the mapping.
|
||||
*/
|
||||
static int
|
||||
dump_map_key(const char *filename, char *key, int verbose)
|
||||
dump_map_key(const char *filename, const char *key, int verbose)
|
||||
{
|
||||
nvlist_t *cfg;
|
||||
int error;
|
||||
|
||||
@@ -25,10 +25,9 @@
|
||||
#include <errno.h>
|
||||
|
||||
static void
|
||||
usage(char *msg, int exit_value)
|
||||
usage(const char *msg, int exit_value)
|
||||
{
|
||||
(void) fprintf(stderr, "get_diff file redacted_file\n");
|
||||
(void) fprintf(stderr, "%s\n", msg);
|
||||
(void) fprintf(stderr, "usage: get_diff file redacted_file\n%s\n", msg);
|
||||
exit(exit_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -596,13 +596,13 @@ test_channel_program(const char *pool)
|
||||
"arg = ...\n"
|
||||
"argv = arg[\"argv\"]\n"
|
||||
"return argv[1]";
|
||||
char *const argv[1] = { "Hello World!" };
|
||||
const char *const argv[1] = { "Hello World!" };
|
||||
nvlist_t *required = fnvlist_alloc();
|
||||
nvlist_t *optional = fnvlist_alloc();
|
||||
nvlist_t *args = fnvlist_alloc();
|
||||
|
||||
fnvlist_add_string(required, "program", program);
|
||||
fnvlist_add_string_array(args, "argv", (const char * const *)argv, 1);
|
||||
fnvlist_add_string_array(args, "argv", argv, 1);
|
||||
fnvlist_add_nvlist(required, "arg", args);
|
||||
|
||||
fnvlist_add_boolean_value(optional, "sync", B_TRUE);
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
|
||||
|
||||
static __attribute__((noreturn)) void
|
||||
usage(char *progname)
|
||||
usage(const char *progname)
|
||||
{
|
||||
(void) fprintf(stderr, "Usage: %s <dirname|filename>\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static __attribute__((noreturn)) void
|
||||
fail(char *err)
|
||||
fail(const char *err)
|
||||
{
|
||||
perror(err);
|
||||
exit(1);
|
||||
|
||||
@@ -21,13 +21,11 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#define MAX_INT_LENGTH 10
|
||||
|
||||
static void
|
||||
usage(char *msg, int exit_value)
|
||||
usage(const char *msg, int exit_value)
|
||||
{
|
||||
(void) fprintf(stderr, "mkfiles basename max_file [min_file]\n");
|
||||
(void) fprintf(stderr, "%s\n", msg);
|
||||
(void) fprintf(stderr, "usage: mkfiles basename max_file [min_file]\n"
|
||||
"%s\n", msg);
|
||||
exit(exit_value);
|
||||
}
|
||||
|
||||
@@ -40,13 +38,13 @@ main(int argc, char **argv)
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
if (argc < 3 || argc > 4)
|
||||
usage("Invalid number of arguments", -1);
|
||||
usage("Invalid number of arguments", 1);
|
||||
|
||||
if (sscanf(argv[2], "%u", &numfiles) != 1)
|
||||
usage("Invalid maximum file", -2);
|
||||
usage("Invalid maximum file", 2);
|
||||
|
||||
if (argc == 4 && sscanf(argv[3], "%u", &first_file) != 1)
|
||||
usage("Invalid first file", -3);
|
||||
usage("Invalid first file", 3);
|
||||
|
||||
for (i = first_file; i < first_file + numfiles; i++) {
|
||||
int fd;
|
||||
@@ -54,11 +52,11 @@ main(int argc, char **argv)
|
||||
if ((fd = open(buf, O_CREAT | O_EXCL, O_RDWR)) == -1) {
|
||||
(void) fprintf(stderr, "Failed to create %s %s\n", buf,
|
||||
strerror(errno));
|
||||
return (-4);
|
||||
return (4);
|
||||
} else if (fchown(fd, getuid(), getgid()) < 0) {
|
||||
(void) fprintf(stderr, "Failed to chown %s %s\n", buf,
|
||||
strerror(errno));
|
||||
return (-5);
|
||||
return (5);
|
||||
}
|
||||
(void) close(fd);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ crtfile(char *pname)
|
||||
{
|
||||
int fd = -1;
|
||||
int i, size;
|
||||
char *context = "0123456789ABCDF";
|
||||
const char *context = "0123456789ABCDF";
|
||||
char *pbuf;
|
||||
|
||||
if (pname == NULL) {
|
||||
|
||||
@@ -84,7 +84,7 @@ nvlist_equal(nvlist_t *nvla, nvlist_t *nvlb)
|
||||
static void
|
||||
test(const char *testname, boolean_t expect_success, boolean_t expect_match)
|
||||
{
|
||||
char *progstr = "input = ...; return {output=input}";
|
||||
const char *progstr = "input = ...; return {output=input}";
|
||||
|
||||
nvlist_t *outnvl;
|
||||
|
||||
@@ -230,8 +230,8 @@ run_tests(void)
|
||||
test("uint64_array", B_FALSE, B_FALSE);
|
||||
}
|
||||
{
|
||||
char *const val[2] = { "0", "1" };
|
||||
fnvlist_add_string_array(nvl, key, (const char **)val, 2);
|
||||
const char *val[2] = { "0", "1" };
|
||||
fnvlist_add_string_array(nvl, key, val, 2);
|
||||
test("string_array", B_TRUE, B_FALSE);
|
||||
}
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *filename = "badfile";
|
||||
const char *filename = "badfile";
|
||||
size_t size = 4395;
|
||||
size_t idx = 0;
|
||||
char *buf = NULL;
|
||||
|
||||
@@ -27,7 +27,7 @@ static char *ifile = NULL;
|
||||
static char *ofile = NULL;
|
||||
static int stride = 0;
|
||||
static int seek = 0;
|
||||
static char *execname = "stride_dd";
|
||||
static const char *execname = "stride_dd";
|
||||
|
||||
static void usage(void);
|
||||
static void parse_options(int argc, char *argv[]);
|
||||
|
||||
@@ -91,8 +91,8 @@ static int size_is_random = 0;
|
||||
static int value_is_random = 0;
|
||||
static int keep_files = 0;
|
||||
static int phase = PHASE_ALL;
|
||||
static char path[PATH_MAX] = "/tmp/xattrtest";
|
||||
static char script[PATH_MAX] = "/bin/true";
|
||||
static const char *path = "/tmp/xattrtest";
|
||||
static const char *script = "/bin/true";
|
||||
static char xattrbytes[XATTR_SIZE_MAX];
|
||||
|
||||
static int
|
||||
@@ -161,8 +161,7 @@ parse_args(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
strncpy(path, optarg, PATH_MAX);
|
||||
path[PATH_MAX - 1] = '\0';
|
||||
path = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
synccaches = 1;
|
||||
@@ -171,8 +170,7 @@ parse_args(int argc, char **argv)
|
||||
dropcaches = 1;
|
||||
break;
|
||||
case 't':
|
||||
strncpy(script, optarg, PATH_MAX);
|
||||
script[PATH_MAX - 1] = '\0';
|
||||
script = optarg;
|
||||
break;
|
||||
case 'e':
|
||||
seed = strtol(optarg, NULL, 0);
|
||||
@@ -291,9 +289,9 @@ run_process(const char *path, char *argv[])
|
||||
}
|
||||
|
||||
static int
|
||||
post_hook(char *phase)
|
||||
post_hook(const char *phase)
|
||||
{
|
||||
char *argv[3] = { script, phase, (char *)0 };
|
||||
char *argv[3] = { (char *)script, (char *)phase, NULL };
|
||||
int rc;
|
||||
|
||||
if (synccaches)
|
||||
@@ -517,9 +515,9 @@ getxattrs(void)
|
||||
int i, j, rnd_size, shift, rc = 0;
|
||||
char name[XATTR_NAME_MAX];
|
||||
char *verify_value = NULL;
|
||||
char *verify_string;
|
||||
const char *verify_string;
|
||||
char *value = NULL;
|
||||
char *value_string;
|
||||
const char *value_string;
|
||||
char *file = NULL;
|
||||
struct timeval start, stop;
|
||||
double seconds;
|
||||
|
||||
Reference in New Issue
Block a user