can-utils: make local functions static

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
pull/504/head
Oliver Hartkopp 2024-03-12 19:58:12 +01:00
parent 8535b1d217
commit dd16f2603b
7 changed files with 46 additions and 40 deletions

View File

@ -62,7 +62,7 @@
extern int optind, opterr, optopt;
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - convert ASC logfile to compact CAN frame logfile.\n", prg);
fprintf(stderr, "Usage: %s\n", prg);
@ -71,7 +71,8 @@ void print_usage(char *prg)
fprintf(stderr, "\t-O <outfile>\t(default stdout)\n");
}
void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, char *extra_info)
static void prframe(FILE *file, struct timeval *tv, int dev,
struct canfd_frame *cf, char *extra_info)
{
static char abuf[BUFLEN];
@ -86,7 +87,7 @@ void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, ch
fprintf(file, "%s%s", abuf, extra_info);
}
void get_can_id(struct canfd_frame *cf, char *idstring, int base)
static void get_can_id(struct canfd_frame *cf, char *idstring, int base)
{
if (idstring[strlen(idstring)-1] == 'x') {
cf->can_id = CAN_EFF_FLAG;
@ -97,7 +98,7 @@ void get_can_id(struct canfd_frame *cf, char *idstring, int base)
cf->can_id |= strtoul(idstring, NULL, base);
}
void calc_tv(struct timeval *tv, struct timeval *read_tv,
static void calc_tv(struct timeval *tv, struct timeval *read_tv,
struct timeval *date_tv, char timestamps, int dplace)
{
if (dplace == 4) /* shift values having only 4 decimal places */
@ -129,7 +130,8 @@ void calc_tv(struct timeval *tv, struct timeval *read_tv,
}
}
void eval_can(char* buf, struct timeval *date_tvp, char timestamps, char base, int dplace, FILE *outfile)
static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
char base, int dplace, FILE *outfile)
{
int interface;
static struct timeval tv; /* current frame timestamp */
@ -239,7 +241,8 @@ void eval_can(char* buf, struct timeval *date_tvp, char timestamps, char base, i
}
}
void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps, int dplace, FILE *outfile)
static void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps,
int dplace, FILE *outfile)
{
int interface;
static struct timeval tv; /* current frame timestamp */
@ -376,7 +379,7 @@ void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps, int dplace
/* No support for really strange CANFD ErrorFrames format m( */
}
int get_date(struct timeval *tv, char *date)
static int get_date(struct timeval *tv, char *date)
{
struct tm tms;
unsigned int msecs = 0;

View File

@ -94,7 +94,7 @@ static unsigned char bargraph;
static enum cfl_mode mode = CFL_WORSTCASE;
static char *prg;
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - monitor CAN bus load.\n", prg);
fprintf(stderr, "\nUsage: %s [options] <CAN interface>+\n", prg);
@ -124,13 +124,13 @@ void print_usage(char *prg)
fprintf(stderr, "\n");
}
void sigterm(int signo)
static void sigterm(int signo)
{
running = 0;
signal_num = signo;
}
void printstats(int signo)
static void printstats(int signo)
{
int i, j, percent;

28
cangw.c
View File

@ -82,8 +82,8 @@ struct fdmodattr {
#define NLMSG_TAIL(nmsg) \
((struct rtattr *)(((char *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
int alen)
static int addattr_l(struct nlmsghdr *n, int maxlen, int type,
const void *data, int alen)
{
int len = RTA_LENGTH(alen);
struct rtattr *rta;
@ -101,7 +101,7 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
return 0;
}
void printfilter(const void *data)
static void printfilter(const void *data)
{
struct can_filter *filter = (struct can_filter *)data;
@ -111,7 +111,7 @@ void printfilter(const void *data)
printf("-f %03X:%X ", filter->can_id, filter->can_mask);
}
void printmod(const char *type, const void *data)
static void printmod(const char *type, const void *data)
{
struct modattr mod;
int i;
@ -137,7 +137,7 @@ void printmod(const char *type, const void *data)
printf(" ");
}
void printfdmod(const char *type, const void *data)
static void printfdmod(const char *type, const void *data)
{
struct fdmodattr mod;
int i;
@ -166,14 +166,14 @@ void printfdmod(const char *type, const void *data)
printf(" ");
}
void print_cs_xor(struct cgw_csum_xor *cs_xor)
static void print_cs_xor(struct cgw_csum_xor *cs_xor)
{
printf("-x %d:%d:%d:%02X ",
cs_xor->from_idx, cs_xor->to_idx,
cs_xor->result_idx, cs_xor->init_xor_val);
}
void print_cs_crc8_profile(struct cgw_csum_crc8 *cs_crc8)
static void print_cs_crc8_profile(struct cgw_csum_crc8 *cs_crc8)
{
int i;
@ -202,7 +202,7 @@ void print_cs_crc8_profile(struct cgw_csum_crc8 *cs_crc8)
printf(" ");
}
void print_cs_crc8(struct cgw_csum_crc8 *cs_crc8)
static void print_cs_crc8(struct cgw_csum_crc8 *cs_crc8)
{
int i;
@ -220,7 +220,7 @@ void print_cs_crc8(struct cgw_csum_crc8 *cs_crc8)
print_cs_crc8_profile(cs_crc8);
}
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - manage PF_CAN netlink gateway.\n", prg);
fprintf(stderr, "\nUsage: %s [options]\n\n", prg);
@ -279,7 +279,7 @@ void print_usage(char *prg)
fprintf(stderr, "\n");
}
int b64hex(char *asc, unsigned char *bin, int len)
static int b64hex(char *asc, unsigned char *bin, int len)
{
int i;
@ -290,7 +290,7 @@ int b64hex(char *asc, unsigned char *bin, int len)
return 0;
}
int parse_crc8_profile(char *optarg, struct cgw_csum_crc8 *crc8)
static int parse_crc8_profile(char *optarg, struct cgw_csum_crc8 *crc8)
{
int ret = 1;
char *ptr;
@ -329,7 +329,7 @@ int parse_crc8_profile(char *optarg, struct cgw_csum_crc8 *crc8)
return ret;
}
int parse_mod(char *optarg, struct modattr *modmsg)
static int parse_mod(char *optarg, struct modattr *modmsg)
{
char *ptr, *nptr;
char hexdata[(CAN_MAX_DLEN * 2) + 1] = {0};
@ -397,7 +397,7 @@ int parse_mod(char *optarg, struct modattr *modmsg)
return 0; /* ok */
}
int parse_fdmod(char *optarg, struct fdmodattr *modmsg)
static int parse_fdmod(char *optarg, struct fdmodattr *modmsg)
{
char *ptr, *nptr;
char hexdata[(CANFD_MAX_DLEN * 2) + 1] = {0};
@ -470,7 +470,7 @@ int parse_fdmod(char *optarg, struct fdmodattr *modmsg)
return 0; /* ok */
}
int parse_rtlist(char *prgname, unsigned char *rxbuf, int len)
static int parse_rtlist(char *prgname, unsigned char *rxbuf, int len)
{
char ifname[IF_NAMESIZE]; /* interface name for if_indextoname() */
struct rtcanmsg *rtc;

View File

@ -83,7 +83,7 @@ extern int optind, opterr, optopt;
static volatile int running = 1;
static volatile sig_atomic_t signal_num;
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - log CAN frames and serves them.\n", prg);
fprintf(stderr, "\nUsage: %s [options] <CAN interface>+\n", prg);
@ -107,7 +107,7 @@ void print_usage(char *prg)
fprintf(stderr, "\n");
}
int idx2dindex(int ifidx, int socket)
static int idx2dindex(int ifidx, int socket)
{
int i;
struct ifreq ifr;
@ -157,7 +157,7 @@ int idx2dindex(int ifidx, int socket)
* This is a Signalhandler. When we get a signal, that a child
* terminated, we wait for it, so the zombie will disappear.
*/
void childdied(int i)
static void childdied(int i)
{
wait(NULL);
}
@ -165,13 +165,12 @@ void childdied(int i)
/*
* This is a Signalhandler for a caught SIGTERM
*/
void shutdown_gra(int i)
static void shutdown_gra(int i)
{
running = 0;
signal_num = i;
}
int main(int argc, char **argv)
{
struct sigaction signalaction;

View File

@ -89,7 +89,7 @@ const int canfx_on = 1;
extern int optind, opterr, optopt;
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - replay a compact CAN frame logfile to CAN devices.\n", prg);
fprintf(stderr, "\nUsage: %s <options> [interface assignment]*\n\n", prg);
@ -172,7 +172,7 @@ static inline int frames_to_send(struct timeval *today, struct timeval *diff, st
return timeval_compare(&cmp, today);
}
int get_txidx(char *logif_name)
static int get_txidx(char *logif_name)
{
int i;
@ -189,7 +189,7 @@ int get_txidx(char *logif_name)
return asgn[i].txifidx; /* return interface index */
}
char *get_txname(char *logif_name)
static char *get_txname(char *logif_name)
{
int i;
@ -206,7 +206,8 @@ char *get_txname(char *logif_name)
return asgn[i].txif; /* return interface name */
}
int add_assignment(char *mode, int socket, char *txname, char *rxname, int verbose)
static int add_assignment(char *mode, int socket, char *txname,
char *rxname, int verbose)
{
struct ifreq ifr;
int i;

View File

@ -56,7 +56,7 @@
extern int optind, opterr, optopt;
void print_usage(char *prg)
static void print_usage(char *prg)
{
fprintf(stderr, "%s - convert compact CAN frame logfile to ASC logfile.\n", prg);
fprintf(stderr, "Usage: %s <options> [can-interfaces]\n", prg);
@ -69,7 +69,8 @@ void print_usage(char *prg)
fprintf(stderr, " -r (suppress dlc for RTR frames - pre v8.5 tools)\n");
}
void can_asc(struct canfd_frame *cfd, int devno, int nortrdlc, char *extra_info, FILE *outfile)
static void can_asc(struct canfd_frame *cfd, int devno, int nortrdlc,
char *extra_info, FILE *outfile)
{
int i;
char id[10];
@ -116,7 +117,8 @@ void can_asc(struct canfd_frame *cfd, int devno, int nortrdlc, char *extra_info,
}
}
void canfd_asc(struct canfd_frame *cf, int devno, int mtu, char *extra_info, FILE *outfile)
static void canfd_asc(struct canfd_frame *cf, int devno, int mtu,
char *extra_info, FILE *outfile)
{
int i;
char id[10];

View File

@ -50,7 +50,8 @@
#define DEVICE_NAME_PTMX "/dev/ptmx"
/* read data from pty, send CAN frames to CAN socket and answer commands */
int pty2can(int pty, int socket, struct can_filter *fi, int *is_open, int *tstamp)
static int pty2can(int pty, int socket, struct can_filter *fi,
int *is_open, int *tstamp)
{
unsigned int nbytes;
char cmd;
@ -313,7 +314,7 @@ rx_out:
}
/* read CAN frames from CAN interface and write it to the pty */
int can2pty(int pty, int socket, int *tstamp)
static int can2pty(int pty, int socket, int *tstamp)
{
int nbytes;
char cmd;
@ -365,7 +366,7 @@ int can2pty(int pty, int socket, int *tstamp)
return 0;
}
int check_select_stdin(void)
static int check_select_stdin(void)
{
fd_set rdfs;
struct timeval timeout;