mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-12-10 10:03:53 +01:00
ipset: fixup compile warnings
And add a few const here and there.
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
|
||||
char program_name[] = "ipset";
|
||||
char program_version[] = IPSET_VERSION;
|
||||
char *xtables_libdir = XTABLES_LIBDIR;
|
||||
const char *xtables_libdir = XTABLES_LIBDIR;
|
||||
|
||||
/* The list of loaded set types */
|
||||
static struct settype *all_settypes = NULL;
|
||||
@@ -53,7 +53,7 @@ void *restore_data = NULL;
|
||||
struct ip_set_restore *restore_set = NULL;
|
||||
size_t restore_offset = 0;
|
||||
socklen_t restore_size;
|
||||
unsigned line = 0;
|
||||
unsigned int g_line = 0;
|
||||
|
||||
#define TEMPFILE_PATTERN "/ipsetXXXXXX"
|
||||
|
||||
@@ -155,7 +155,7 @@ static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] = {
|
||||
/* Main parser function */
|
||||
int parse_commandline(int argc, char *argv[]);
|
||||
|
||||
void exit_tryhelp(int status)
|
||||
static void exit_tryhelp(int status)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Try `%s -H' or '%s --help' for more information.\n",
|
||||
@@ -163,7 +163,7 @@ void exit_tryhelp(int status)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
void exit_error(enum exittype status, char *msg, ...)
|
||||
void exit_error(enum exittype status, const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -173,8 +173,8 @@ void exit_error(enum exittype status, char *msg, ...)
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
if (line)
|
||||
fprintf(stderr, "Restore failed at line %u:\n", line);
|
||||
if (g_line)
|
||||
fprintf(stderr, "Restore failed at line %u:\n", g_line);
|
||||
if (status == PARAMETER_PROBLEM)
|
||||
exit_tryhelp(status);
|
||||
if (status == VERSION_PROBLEM)
|
||||
@@ -186,7 +186,7 @@ void exit_error(enum exittype status, char *msg, ...)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
void ipset_printf(char *msg, ...)
|
||||
static void ipset_printf(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -896,12 +896,12 @@ static struct set *set_find_byname(const char *name)
|
||||
|
||||
static ip_set_id_t set_find_free_index(const char *name)
|
||||
{
|
||||
ip_set_id_t i, index = IP_SET_INVALID_ID;
|
||||
ip_set_id_t i, idx = IP_SET_INVALID_ID;
|
||||
|
||||
for (i = 0; i < max_sets; i++) {
|
||||
if (index == IP_SET_INVALID_ID
|
||||
if (idx == IP_SET_INVALID_ID
|
||||
&& set_list[i] == NULL)
|
||||
index = i;
|
||||
idx = i;
|
||||
if (set_list[i] != NULL
|
||||
&& strncmp(set_list[i]->name, name,
|
||||
IP_SET_MAXNAMELEN) == 0)
|
||||
@@ -910,13 +910,13 @@ static ip_set_id_t set_find_free_index(const char *name)
|
||||
name);
|
||||
}
|
||||
|
||||
if (index == IP_SET_INVALID_ID)
|
||||
if (idx == IP_SET_INVALID_ID)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"Set %s cannot be restored, "
|
||||
"max number of set %u reached",
|
||||
name, max_sets);
|
||||
|
||||
return index;
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1035,7 +1035,7 @@ static void set_rename(const char *name, const char *newname,
|
||||
* Send MAX_SETS, LIST_SIZE and/or SAVE_SIZE orders to kernel
|
||||
*/
|
||||
static size_t load_set_list(const char name[IP_SET_MAXNAMELEN],
|
||||
ip_set_id_t *index,
|
||||
ip_set_id_t *idx,
|
||||
unsigned op, unsigned cmd)
|
||||
{
|
||||
void *data = NULL;
|
||||
@@ -1072,7 +1072,7 @@ tryagain:
|
||||
max_sets = req_max_sets.max_sets;
|
||||
set_list = ipset_malloc(max_sets * sizeof(struct set *));
|
||||
memset(set_list, 0, max_sets * sizeof(struct set *));
|
||||
*index = req_max_sets.set.index;
|
||||
*idx = req_max_sets.set.index;
|
||||
|
||||
if (req_max_sets.sets == 0)
|
||||
/* No sets in kernel */
|
||||
@@ -1083,7 +1083,7 @@ tryagain:
|
||||
+ req_max_sets.sets * sizeof(struct ip_set_name_list);
|
||||
data = ipset_malloc(size);
|
||||
((struct ip_set_req_setnames *) data)->op = op;
|
||||
((struct ip_set_req_setnames *) data)->index = *index;
|
||||
((struct ip_set_req_setnames *) data)->index = *idx;
|
||||
|
||||
res = kernel_getfrom_handleerrno(cmd, data, &size);
|
||||
|
||||
@@ -1222,12 +1222,12 @@ static int try_save_sets(const char name[IP_SET_MAXNAMELEN])
|
||||
{
|
||||
void *data = NULL;
|
||||
socklen_t size, req_size = 0;
|
||||
ip_set_id_t index;
|
||||
ip_set_id_t idx;
|
||||
int res = 0, bindings = 0;
|
||||
time_t now = time(NULL);
|
||||
|
||||
/* Load set_list from kernel */
|
||||
size = load_set_list(name, &index,
|
||||
size = load_set_list(name, &idx,
|
||||
IP_SET_OP_SAVE_SIZE, CMD_SAVE);
|
||||
|
||||
if (size) {
|
||||
@@ -1236,7 +1236,7 @@ static int try_save_sets(const char name[IP_SET_MAXNAMELEN])
|
||||
req_size = (size += sizeof(struct ip_set_save));
|
||||
data = ipset_malloc(size);
|
||||
((struct ip_set_req_list *) data)->op = IP_SET_OP_SAVE;
|
||||
((struct ip_set_req_list *) data)->index = index;
|
||||
((struct ip_set_req_list *) data)->index = idx;
|
||||
res = kernel_getfrom_handleerrno(CMD_SAVE, data, &size);
|
||||
|
||||
if (res != 0 || size != req_size) {
|
||||
@@ -1360,7 +1360,7 @@ static void set_restore(char *argv0)
|
||||
int line = 0, first_pass, i, bindings = 0;
|
||||
struct settype *settype = NULL;
|
||||
struct ip_set_req_setnames *header;
|
||||
ip_set_id_t index;
|
||||
ip_set_id_t idx;
|
||||
FILE *in;
|
||||
int res;
|
||||
|
||||
@@ -1368,7 +1368,7 @@ static void set_restore(char *argv0)
|
||||
in = create_tempfile();
|
||||
|
||||
/* Load existing sets from kernel */
|
||||
load_set_list(IPSET_TOKEN_ALL, &index,
|
||||
load_set_list(IPSET_TOKEN_ALL, &idx,
|
||||
IP_SET_OP_LIST_SIZE, CMD_RESTORE);
|
||||
|
||||
restore_size = sizeof(struct ip_set_req_setnames)/* header */
|
||||
@@ -1797,20 +1797,20 @@ static int try_list_sets(const char name[IP_SET_MAXNAMELEN],
|
||||
unsigned options)
|
||||
{
|
||||
void *data = NULL;
|
||||
ip_set_id_t index;
|
||||
ip_set_id_t idx;
|
||||
socklen_t size, req_size;
|
||||
int res = 0;
|
||||
|
||||
DP("%s", name);
|
||||
/* Load set_list from kernel */
|
||||
size = req_size = load_set_list(name, &index,
|
||||
size = req_size = load_set_list(name, &idx,
|
||||
IP_SET_OP_LIST_SIZE, CMD_LIST);
|
||||
|
||||
if (size) {
|
||||
/* Get sets and print them */
|
||||
data = ipset_malloc(size);
|
||||
((struct ip_set_req_list *) data)->op = IP_SET_OP_LIST;
|
||||
((struct ip_set_req_list *) data)->index = index;
|
||||
((struct ip_set_req_list *) data)->index = idx;
|
||||
res = kernel_getfrom_handleerrno(CMD_LIST, data, &size);
|
||||
DP("get_lists getsockopt() res=%d errno=%d", res, errno);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user