Merge pull request #160 from BarbarossaTM/chore/pedantic-gcc
Make gcc complain more and treat warnings as errors
This commit is contained in:
commit
7a46b61996
11 changed files with 48 additions and 23 deletions
3
Makefile
3
Makefile
|
@ -14,7 +14,8 @@ CONFIG_FILE := /etc/network/ifupdown-ng.conf
|
||||||
EXECUTOR_PATH := /usr/libexec/ifupdown-ng
|
EXECUTOR_PATH := /usr/libexec/ifupdown-ng
|
||||||
|
|
||||||
CFLAGS ?= -ggdb3 -Os
|
CFLAGS ?= -ggdb3 -Os
|
||||||
CFLAGS += -Wall -Wextra
|
CFLAGS += -Wall -Wextra -Werror
|
||||||
|
CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wcast-align -Wpointer-arith -Wreturn-type
|
||||||
CFLAGS += ${LIBBSD_CFLAGS}
|
CFLAGS += ${LIBBSD_CFLAGS}
|
||||||
CPPFLAGS = -I.
|
CPPFLAGS = -I.
|
||||||
CPPFLAGS += -DINTERFACES_FILE=\"${INTERFACES_FILE}\"
|
CPPFLAGS += -DINTERFACES_FILE=\"${INTERFACES_FILE}\"
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "multicall.h"
|
#include "cmd/multicall.h"
|
||||||
|
#include "cmd/ifctrstat-linux.h"
|
||||||
|
|
||||||
struct counter_desc {
|
struct counter_desc {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -41,7 +42,7 @@ counter_compare(const void *key, const void *candidate)
|
||||||
return strcasecmp((const char *)key, ((struct counter_desc *)candidate)->name);
|
return strcasecmp((const char *)key, ((struct counter_desc *)candidate)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
read_counter(const char *interface, const char *counter)
|
read_counter(const char *interface, const char *counter)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
22
cmd/ifctrstat-linux.h
Normal file
22
cmd/ifctrstat-linux.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* cmd/ifctrstat-linux.c
|
||||||
|
* Purpose: Implement ifctrstat system-specific routines for Linux
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Maximilian Wilhelm <max@sdn.clinic>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* This software is provided 'as is' and without any warranty, express or
|
||||||
|
* implied. In no event shall the authors be liable for any damages arising
|
||||||
|
* from the use of this software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD
|
||||||
|
#define IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD
|
||||||
|
|
||||||
|
extern const char * read_counter(const char *interface, const char *counter);
|
||||||
|
|
||||||
|
#endif
|
|
@ -20,12 +20,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libifupdown/libifupdown.h"
|
#include "libifupdown/libifupdown.h"
|
||||||
#include "cmd/multicall.h"
|
#include "cmd/multicall.h"
|
||||||
|
#include "cmd/ifctrstat-linux.h"
|
||||||
|
|
||||||
extern struct counter_desc { const char *name; const void *data; } avail_counters[];
|
extern struct counter_desc { const char *name; const void *data; } avail_counters[];
|
||||||
extern int avail_counters_count;
|
extern int avail_counters_count;
|
||||||
|
|
||||||
extern const char *read_counter(const char *interface, const char *counter);
|
|
||||||
|
|
||||||
static bool show_label = true;
|
static bool show_label = true;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -96,7 +95,7 @@ ifctrstat_set_nolabel(const char *opt_arg)
|
||||||
show_label = false;
|
show_label = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ifctrstat_main(int argc, char *argv[])
|
ifctrstat_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (optind >= argc)
|
if (optind >= argc)
|
||||||
|
|
|
@ -131,7 +131,7 @@ pp_impl_cmp(const void *a, const void *b)
|
||||||
return strcmp(key, impl->name);
|
return strcmp(key, impl->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ifparse_main(int argc, char *argv[])
|
ifparse_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lif_dict state = {};
|
struct lif_dict state = {};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "cmd/multicall.h"
|
#include "cmd/multicall.h"
|
||||||
#include "cmd/pretty-print-iface.h"
|
#include "cmd/pretty-print-iface.h"
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, struct lif_interface *parent)
|
print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, struct lif_interface *parent)
|
||||||
{
|
{
|
||||||
if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname))
|
if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname))
|
||||||
|
@ -57,7 +57,7 @@ print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
print_interface_property(struct lif_interface *iface, const char *property)
|
print_interface_property(struct lif_interface *iface, const char *property)
|
||||||
{
|
{
|
||||||
struct lif_node *iter;
|
struct lif_node *iter;
|
||||||
|
@ -83,7 +83,7 @@ print_interface_property(struct lif_interface *iface, const char *property)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
list_interfaces(struct lif_dict *collection, struct match_options *opts)
|
list_interfaces(struct lif_dict *collection, struct match_options *opts)
|
||||||
{
|
{
|
||||||
struct lif_node *iter;
|
struct lif_node *iter;
|
||||||
|
@ -126,7 +126,7 @@ list_interfaces(struct lif_dict *collection, struct match_options *opts)
|
||||||
static bool listing = false, listing_stat = false, listing_running = false;
|
static bool listing = false, listing_stat = false, listing_running = false;
|
||||||
static bool allow_undefined = false;
|
static bool allow_undefined = false;
|
||||||
|
|
||||||
void
|
static void
|
||||||
list_state(struct lif_dict *state, struct match_options *opts)
|
list_state(struct lif_dict *state, struct match_options *opts)
|
||||||
{
|
{
|
||||||
struct lif_node *iter;
|
struct lif_node *iter;
|
||||||
|
@ -217,7 +217,7 @@ static struct if_option_group local_option_group = {
|
||||||
.group = local_options
|
.group = local_options
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
static int
|
||||||
ifquery_main(int argc, char *argv[])
|
ifquery_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lif_dict state = {};
|
struct lif_dict state = {};
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
static bool up;
|
static bool up;
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
is_ifdown()
|
is_ifdown()
|
||||||
{
|
{
|
||||||
if (strstr(argv0, "ifdown") != NULL)
|
if (strstr(argv0, "ifdown") != NULL)
|
||||||
|
@ -36,7 +36,7 @@ is_ifdown()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
acquire_state_lock(const char *state_path, const char *lifname)
|
acquire_state_lock(const char *state_path, const char *lifname)
|
||||||
{
|
{
|
||||||
if (exec_opts.mock || exec_opts.no_lock)
|
if (exec_opts.mock || exec_opts.no_lock)
|
||||||
|
@ -94,7 +94,7 @@ acquire_state_lock(const char *state_path, const char *lifname)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict *state, bool update_state)
|
skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict *state, bool update_state)
|
||||||
{
|
{
|
||||||
if (iface->is_template)
|
if (iface->is_template)
|
||||||
|
@ -146,7 +146,7 @@ skip_interface(struct lif_interface *iface, const char *ifname, struct lif_dict
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname, bool update_state)
|
change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname, bool update_state)
|
||||||
{
|
{
|
||||||
int lockfd = acquire_state_lock(exec_opts.state_file, ifname);
|
int lockfd = acquire_state_lock(exec_opts.state_file, ifname);
|
||||||
|
@ -194,7 +194,7 @@ change_interface(struct lif_interface *iface, struct lif_dict *collection, struc
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, struct match_options *opts)
|
change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, struct match_options *opts)
|
||||||
{
|
{
|
||||||
struct lif_node *iter;
|
struct lif_node *iter;
|
||||||
|
@ -222,7 +222,7 @@ change_auto_interfaces(struct lif_dict *collection, struct lif_dict *state, stru
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
update_state_file_and_exit(int rc, struct lif_dict *state)
|
update_state_file_and_exit(int rc, struct lif_dict *state)
|
||||||
{
|
{
|
||||||
if (exec_opts.mock)
|
if (exec_opts.mock)
|
||||||
|
@ -243,7 +243,7 @@ update_state_file_and_exit(int rc, struct lif_dict *state)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ifupdown_main(int argc, char *argv[])
|
ifupdown_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
up = !is_ifdown();
|
up = !is_ifdown();
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct if_applet *applet_table[] = {
|
||||||
&ifupdown_applet,
|
&ifupdown_applet,
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
static int
|
||||||
applet_cmp(const void *a, const void *b)
|
applet_cmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const char *key = a;
|
const char *key = a;
|
||||||
|
@ -101,7 +101,7 @@ main(int argc, char *argv[])
|
||||||
return self_applet->main(argc, argv);
|
return self_applet->main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
multicall_main(int argc, char *argv[])
|
multicall_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "libifupdown/compat.h"
|
||||||
#include "libifupdown/config-file.h"
|
#include "libifupdown/config-file.h"
|
||||||
#include "libifupdown/dict.h"
|
#include "libifupdown/dict.h"
|
||||||
#include "libifupdown/interface.h"
|
#include "libifupdown/interface.h"
|
||||||
|
@ -102,7 +103,7 @@ compat_ifupdown2_bridge_ports_inherit_vlans(struct lif_dict *collection)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool
|
bool
|
||||||
lif_compat_apply(struct lif_dict *collection)
|
lif_compat_apply(struct lif_dict *collection)
|
||||||
{
|
{
|
||||||
if (lif_config.compat_ifupdown2_bridge_ports_inherit_vlans &&
|
if (lif_config.compat_ifupdown2_bridge_ports_inherit_vlans &&
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define LIBIFUPDOWN__COMPAT_H
|
#define LIBIFUPDOWN__COMPAT_H
|
||||||
|
|
||||||
#include "libifupdown/config-file.h"
|
#include "libifupdown/config-file.h"
|
||||||
|
#include "libifupdown/dict.h"
|
||||||
|
|
||||||
extern bool lif_compat_apply (struct lif_dict *collection);
|
extern bool lif_compat_apply (struct lif_dict *collection);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ query_dependents_from_executors(const struct lif_execute_opts *opts, char *const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
append_to_buffer(char **buffer, size_t *buffer_len, char **end, const char *value)
|
append_to_buffer(char **buffer, size_t *buffer_len, char **end, const char *value)
|
||||||
{
|
{
|
||||||
size_t value_len = strlen (value);
|
size_t value_len = strlen (value);
|
||||||
|
|
Loading…
Reference in a new issue