From 24dd3413f5ac7c1ba6ce1de1ec7509ecfa2e8ccd Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Mon, 28 Jul 2003 08:14:27 +0000 Subject: [PATCH] Make atm WARNS=6 clean. The changes are mostly: - remove some instances of __P() - use real prototypes and un-K&R function headers - constify where necessary (mostly strings and structures containing strings) - make functions and variables static that need not to be global - tag unused function parameters as __unused Testing: a fresh universe --- sbin/atm/atm/Makefile | 2 +- sbin/atm/atm/atm.c | 171 ++++++++++++++++--------------------- sbin/atm/atm/atm.h | 115 ++++++++++--------------- sbin/atm/atm/atm_eni.c | 9 +- sbin/atm/atm/atm_fore200.c | 14 ++- sbin/atm/atm/atm_inet.c | 26 +++--- sbin/atm/atm/atm_print.c | 82 +++++++++--------- sbin/atm/atm/atm_set.c | 29 ++----- sbin/atm/atm/atm_show.c | 146 +++++++++++++------------------ sbin/atm/atm/atm_subr.c | 87 ++++++++++--------- 10 files changed, 299 insertions(+), 382 deletions(-) diff --git a/sbin/atm/atm/Makefile b/sbin/atm/atm/Makefile index 1ea91e9e716..494552d9842 100644 --- a/sbin/atm/atm/Makefile +++ b/sbin/atm/atm/Makefile @@ -33,7 +33,7 @@ SRCS= atm.c atm_fore200.c atm_eni.c atm_inet.c atm_print.c \ MAN= atm.8 CFLAGS+= -I${.CURDIR}/../../../sys -WARNS= 0 +WARNS= 6 LDADD+= -latm DPADD+= ${LIBATM} diff --git a/sbin/atm/atm/atm.c b/sbin/atm/atm/atm.c index 35666603523..d156e69de7e 100644 --- a/sbin/atm/atm/atm.c +++ b/sbin/atm/atm/atm.c @@ -103,38 +103,50 @@ Miscellaneous subcommands:\n\ /* * Local definitions */ - -struct cmd add_subcmd[]; -struct cmd dlt_subcmd[]; -struct cmd set_subcmd[]; -struct cmd show_subcmd[]; -struct cmd stats_subcmd[]; - -struct cmd cmds[] = { - { "add", 0, 0, NULL, (char *) add_subcmd }, +static int do_cmd(const struct cmd *, int, char **); +static void usage(const struct cmd *, const char *); + +static void attach(int, char **, const struct cmd *); +static void detach(int, char **, const struct cmd *); +static void help(int, char **, const struct cmd *); +static void arp_add(int, char **, const struct cmd *); +static void pvc_add(int, char **, const struct cmd *); +static void pvc_dlt(int, char **, const struct cmd *); +static void svc_dlt(int, char **, const struct cmd *); +static void arp_dlt(int, char **, const struct cmd *); +static void vcc_dlt(int, char **, const struct cmd *, struct atmdelreq *); + +static const struct cmd add_subcmd[]; +static const struct cmd dlt_subcmd[]; +static const struct cmd set_subcmd[]; +static const struct cmd show_subcmd[]; +static const struct cmd stats_subcmd[]; + +static const struct cmd cmds[] = { + { "add", 0, 0, NULL, (const char *)add_subcmd }, { "attach", 2, 2, attach, " " }, - { "delete", 0, 0, NULL, (char *) dlt_subcmd }, + { "delete", 0, 0, NULL, (const char *)dlt_subcmd }, { "detach", 1, 1, detach, "" }, - { "set", 0, 0, NULL, (char *) set_subcmd }, - { "show", 0, 0, NULL, (char *) show_subcmd }, + { "set", 0, 0, NULL, (const char *)set_subcmd }, + { "show", 0, 0, NULL, (const char *)show_subcmd }, { "help", 0, 99, help, "" }, { 0, 0, 0, NULL, "" } }; -struct cmd add_subcmd[] = { +static const struct cmd add_subcmd[] = { { "arp", 2, 3, arp_add, "[] " }, { "pvc", 6, 12, pvc_add, " ..." }, { 0, 0, 0, NULL, "" } }; -struct cmd dlt_subcmd[] = { +static const struct cmd dlt_subcmd[] = { { "arp", 1, 2, arp_dlt, "[] " }, { "pvc", 3, 3, pvc_dlt, " " }, { "svc", 3, 3, svc_dlt, " " }, { 0, 0, 0, NULL, "" } }; -struct cmd set_subcmd[] = { +static const struct cmd set_subcmd[] = { { "arpserver", 2, 18, set_arpserver, " " }, { "mac", 2, 2, set_macaddr, " " }, { "netif", 3, 3, set_netif, " " }, @@ -142,20 +154,20 @@ struct cmd set_subcmd[] = { { 0, 0, 0, NULL, ""} }; -struct cmd show_subcmd[] = { +static const struct cmd show_subcmd[] = { { "arp", 0, 1, show_arp, "[]" }, { "arpserver", 0, 1, show_arpserv, "[]" }, { "config", 0, 1, show_config, "[]" }, { "interface", 0, 1, show_intf, "[]" }, { "ipvcc", 0, 3, show_ip_vcc, "[ | ]" }, { "netif", 0, 1, show_netif, "[]" }, - { "stats", 0, 3, NULL, (char *) stats_subcmd }, + { "stats", 0, 3, NULL, (const char *)stats_subcmd }, { "vcc", 0, 3, show_vcc, "[] [ [] | SVC | PVC]" }, { "version", 0, 0, show_version, "" }, { 0, 0, 0, NULL, "" } }; -struct cmd stats_subcmd[] = { +static const struct cmd stats_subcmd[] = { { "interface", 0, 2, show_intf_stats, "[ [cfg | phy | dev | atm | aal0 | aal4 | aal5 | driver]]" }, { "vcc", 0, 3, show_vcc_stats, "[ [vpi [vci]]]" }, { 0, 0, 0, NULL, "" } @@ -165,7 +177,7 @@ struct cmd stats_subcmd[] = { /* * Supported signalling protocols */ -struct proto protos[] = { +static const struct proto protos[] = { { "SIGPVC", ATM_SIG_PVC }, { "SPANS", ATM_SIG_SPANS }, { "UNI30", ATM_SIG_UNI30 }, @@ -177,7 +189,7 @@ struct proto protos[] = { /* * Supported VCC owners */ -struct owner owners[] = { +static const struct owner owners[] = { { "IP", ENDPT_IP, ip_pvcadd }, { "SPANS", ENDPT_SPANS_SIG,0 }, { "SPANS CLS", ENDPT_SPANS_CLS,0 }, @@ -188,7 +200,7 @@ struct owner owners[] = { /* * Supported AAL parameters */ -struct aal aals[] = { +const struct aal aals[] = { { "Null", ATM_AAL0 }, { "AAL0", ATM_AAL0 }, { "AAL1", ATM_AAL1 }, @@ -203,7 +215,7 @@ struct aal aals[] = { /* * Supported VCC encapsulations */ -struct encaps encaps[] = { +const struct encaps encaps[] = { { "Null", ATM_ENC_NULL }, { "None", ATM_ENC_NULL }, { "LLC/SNAP", ATM_ENC_LLC }, @@ -212,15 +224,11 @@ struct encaps encaps[] = { { 0, 0 }, }; - char *prog; char prefix[128] = ""; - int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { int error; @@ -260,13 +268,10 @@ main(argc, argv) * none * */ -int -do_cmd(descp, argc, argv) - struct cmd *descp; - int argc; - char **argv; +static int +do_cmd(const struct cmd *descp, int argc, char **argv) { - struct cmd *cmdp = 0; + const struct cmd *cmdp = NULL; /* * Make sure we have paramaters to process @@ -309,7 +314,8 @@ do_cmd(descp, argc, argv) if (cmdp->func == NULL) { strcat(prefix, cmdp->name); strcat(prefix, " "); - return(do_cmd((struct cmd *)cmdp->help, argc, argv)); + return (do_cmd((const struct cmd *)(const void *)cmdp->help, + argc, argv)); } /* @@ -342,10 +348,8 @@ do_cmd(descp, argc, argv) * none * */ -void -usage(cmdp, pref) - struct cmd *cmdp; - char *pref; +static void +usage(const struct cmd *cmdp __unused, const char *pref __unused) { fprintf(stderr, "usage: %s command [arg] [arg]...\n", prog); fprintf(stderr, USAGE_STR); @@ -367,14 +371,11 @@ usage(cmdp, pref) * none * */ -void -attach(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +attach(int argc __unused, char **argv, const struct cmd *cmdp __unused) { struct atmcfgreq aar; - struct proto *prp; + const struct proto *prp; int s; /* @@ -466,11 +467,8 @@ attach(argc, argv, cmdp) * none * */ -void -detach(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +detach(int argc __unused, char **argv, const struct cmd *cmdp __unused) { struct atmcfgreq adr; int s; @@ -535,18 +533,15 @@ detach(argc, argv, cmdp) * none * */ -void -pvc_add(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +pvc_add(int argc, char **argv, const struct cmd *cmdp) { struct atmaddreq apr; struct atminfreq air; struct air_int_rsp *int_info; - struct owner *owp; - struct aal *alp; - struct encaps *enp; + const struct owner *owp; + const struct aal *alp; + const struct encaps *enp; char *cp; long v; int buf_len, s; @@ -587,7 +582,7 @@ pvc_add(argc, argv, cmdp) } exit(1); } - int_info = (struct air_int_rsp *) air.air_buf_addr; + int_info = (struct air_int_rsp *)(void *)air.air_buf_addr; strcpy(apr.aar_pvc_intf, argv[0]); argc--; argv++; @@ -719,18 +714,15 @@ pvc_add(argc, argv, cmdp) * none * */ -void -arp_add(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +arp_add(int argc, char **argv, const struct cmd *cmdp __unused) { int len, s; struct atmaddreq apr; Atm_addr host_atm; - struct sockaddr_in *sin; + struct sockaddr_in *sain; union { - struct sockaddr_in sin; + struct sockaddr_in sain; struct sockaddr sa; } host_ip; @@ -753,8 +745,8 @@ arp_add(argc, argv, cmdp) */ bzero(&host_ip, sizeof(host_ip)); host_ip.sa.sa_family = AF_INET; - sin = get_ip_addr(argv[0]); - host_ip.sin.sin_addr.s_addr = sin->sin_addr.s_addr; + sain = get_ip_addr(argv[0]); + host_ip.sain.sin_addr.s_addr = sain->sin_addr.s_addr; argc--; argv++; /* @@ -828,11 +820,8 @@ arp_add(argc, argv, cmdp) * none * */ -void -pvc_dlt(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +pvc_dlt(int argc, char **argv, const struct cmd *cmdp) { struct atmdelreq apr; @@ -863,11 +852,8 @@ pvc_dlt(argc, argv, cmdp) * none * */ -void -svc_dlt(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +svc_dlt(int argc, char **argv, const struct cmd *cmdp) { struct atmdelreq apr; @@ -896,12 +882,9 @@ svc_dlt(argc, argv, cmdp) * none * */ -void -vcc_dlt(argc, argv, cmdp, apr) - int argc; - char **argv; - struct cmd *cmdp; - struct atmdelreq *apr; +static void +vcc_dlt(int argc, char **argv, const struct cmd *cmdp __unused, + struct atmdelreq *apr) { char *cp; long v; @@ -987,17 +970,14 @@ vcc_dlt(argc, argv, cmdp, apr) * none * */ -void -arp_dlt(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +arp_dlt(int argc, char **argv, const struct cmd *cmdp __unused) { int s; struct atmdelreq apr; - struct sockaddr_in *sin; + struct sockaddr_in *sain; union { - struct sockaddr_in sin; + struct sockaddr_in sain; struct sockaddr sa; } host_addr; @@ -1021,8 +1001,8 @@ arp_dlt(argc, argv, cmdp) */ bzero(&host_addr, sizeof(host_addr)); host_addr.sa.sa_family = AF_INET; - sin = get_ip_addr(argv[0]); - host_addr.sin.sin_addr.s_addr = sin->sin_addr.s_addr; + sain = get_ip_addr(argv[0]); + host_addr.sain.sin_addr.s_addr = sain->sin_addr.s_addr; apr.adr_arp_dst = host_addr.sa; /* @@ -1063,11 +1043,8 @@ arp_dlt(argc, argv, cmdp) * none * */ -void -help(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +static void +help(int argc __unused, char **argv __unused, const struct cmd *cmdp __unused) { usage(cmds, ""); } diff --git a/sbin/atm/atm/atm.h b/sbin/atm/atm/atm.h index ff006b46c85..b53733ac3ac 100644 --- a/sbin/atm/atm/atm.h +++ b/sbin/atm/atm/atm.h @@ -50,12 +50,12 @@ * User commands */ struct cmd { - char *name; /* Command name */ + const char *name; /* Command name */ int minp; /* Minimum number of parameters */ int maxp; /* Maximum number of parameters */ - void (*func) /* Processing function */ -(int, char **, struct cmd *); - char *help; /* User help string */ + void (*func)(int, char **, + const struct cmd *);/* Processing function */ + const char *help; /* User help string */ }; @@ -63,7 +63,7 @@ struct cmd { * Supported signalling protocols */ struct proto { - char *p_name; /* Protocol name */ + const char *p_name; /* Protocol name */ u_char p_id; /* Protocol id */ }; @@ -72,7 +72,7 @@ struct proto { * Table of state names */ struct state { - char *s_name; /* State name */ + const char *s_name; /* State name */ u_char s_id; /* State id */ }; @@ -81,9 +81,9 @@ struct state { * Supported signalling protocol states */ struct proto_state { - char *p_name; /* Signalling manager name */ - struct state *p_state; /* Protocol state table */ - struct state *v_state; /* Protocol VCC state table */ + const char *p_name; /* Signalling manager name */ + const struct state *p_state; /* Protocol state table */ + const struct state *v_state; /* Protocol VCC state table */ u_char p_id; /* Protocol ID */ }; @@ -92,11 +92,11 @@ struct proto_state { * Supported VCC owners */ struct owner { - char *o_name; /* Owner name */ + const char *o_name; /* Owner name */ u_int o_sap; /* Owner's SAP */ - void (*o_pvcadd) /* PVC ADD processing function */ - __P((int, char **, struct cmd *, struct atmaddreq *, - struct air_int_rsp *)); + void (*o_pvcadd)(int, char **, const struct cmd *, + struct atmaddreq *, struct air_int_rsp *); + /* PVC ADD processing function */ }; @@ -104,7 +104,7 @@ struct owner { * Supported AALs */ struct aal { - char *a_name; /* AAL name */ + const char *a_name; /* AAL name */ u_char a_id; /* AAL code */ }; @@ -113,11 +113,10 @@ struct aal { * Supported encapsulations */ struct encaps { - char *e_name; /* Encapsulation name */ + const char *e_name; /* Encapsulation name */ u_char e_id; /* Encapsulation code */ }; - /* * External variables */ @@ -127,41 +126,16 @@ extern char prefix[]; /* Current command prefix */ /* * Global function declarations */ - /* atm.c */ -int do_cmd(struct cmd *, int, char **); -void usage(struct cmd *, char *); -void attach(int, char **, struct cmd *); -void detach(int, char **, struct cmd *); -void pvc_add(int, char **, struct cmd *); -void arp_add(int, char **, struct cmd *); -void pvc_dlt(int, char **, struct cmd *); -void svc_dlt(int, char **, struct cmd *); -void vcc_dlt(int, char **, struct cmd *, struct atmdelreq *); -void arp_dlt(int, char **, struct cmd *); -void help(int, char **, struct cmd *); /* atm_eni.c */ void show_eni_stats(char *, int, char **); -void print_eni_oc3(struct air_vinfo_rsp *); -void print_eni_atm(struct air_vinfo_rsp *); -void print_eni_aal0(struct air_vinfo_rsp *); -void print_eni_aal5(struct air_vinfo_rsp *); -void print_eni_driver(struct air_vinfo_rsp *); /* atm_fore200.c */ void show_fore200_stats(char *, int, char **); -void print_fore200_taxi(struct air_vinfo_rsp *); -void print_fore200_oc3(struct air_vinfo_rsp *); -void print_fore200_dev(struct air_vinfo_rsp *); -void print_fore200_atm(struct air_vinfo_rsp *); -void print_fore200_aal0(struct air_vinfo_rsp *); -void print_fore200_aal4(struct air_vinfo_rsp *); -void print_fore200_aal5(struct air_vinfo_rsp *); -void print_fore200_driver(struct air_vinfo_rsp *); /* atm_inet.c */ -void ip_pvcadd __P((int, char **, struct cmd *, struct atmaddreq *, - struct air_int_rsp *)); +void ip_pvcadd(int, char **, const struct cmd *, struct atmaddreq *, + struct air_int_rsp *); /* atm_print.c */ void print_arp_info(struct air_arp_rsp *); @@ -176,38 +150,37 @@ void print_vcc_info(struct air_vcc_rsp *); void print_version_info(struct air_version_rsp *); /* atm_set.c */ -void set_arpserver(int, char **, struct cmd *); -void set_macaddr(int, char **, struct cmd *); -void set_netif(int, char **, struct cmd *); -void set_prefix(int, char **, struct cmd *); +void set_arpserver(int, char **, const struct cmd *); +void set_macaddr(int, char **, const struct cmd *); +void set_netif(int, char **, const struct cmd *); +void set_prefix(int, char **, const struct cmd *); /* atm_show.c */ -void show_arp(int, char **, struct cmd *); -void show_arpserv(int, char **, struct cmd *); -void show_config(int, char **, struct cmd *); -void show_intf(int, char **, struct cmd *); -void show_ip_vcc(int, char **, struct cmd *); -void show_netif(int, char **, struct cmd *); -void show_intf_stats(int, char **, struct cmd *); -void show_vcc_stats(int, char **, struct cmd *); -void show_vcc(int, char **, struct cmd *); -void show_version(int, char **, struct cmd *); +void show_arp(int, char **, const struct cmd *); +void show_arpserv(int, char **, const struct cmd *); +void show_config(int, char **, const struct cmd *); +void show_intf(int, char **, const struct cmd *); +void show_ip_vcc(int, char **, const struct cmd *); +void show_netif(int, char **, const struct cmd *); +void show_vcc(int, char **, const struct cmd *); +void show_version(int, char **, const struct cmd *); +void show_intf_stats(int, char **, const struct cmd *); +void show_vcc_stats(int, char **, const struct cmd *); /* atm_subr.c */ -char * get_vendor(int); -char * get_adapter(int); -char * get_media_type(int); -char * get_bus_type(int); -char * get_bus_slot_info(int, u_long); -char * get_adapter_name(char *); -int do_info_ioctl(struct atminfreq *, int); -int get_vcc_info(char *, struct air_vcc_rsp **); -int verify_nif_name(char *); -struct sockaddr_in * - get_ip_addr(char *); +const char * get_vendor(int); +const char * get_adapter(int); +const char * get_media_type(int); +const char * get_bus_type(int); +const char * get_bus_slot_info(int, u_long); +const char * get_adapter_name(const char *); int get_hex_addr(char *, u_char *, int); -char * format_mac_addr(Mac_addr *); -int parse_ip_prefix(char *, struct in_addr *); +const char * format_mac_addr(const Mac_addr *); +int parse_ip_prefix(const char *, struct in_addr *); int compress_prefix_list(struct in_addr *, int); -void check_netif_name(char *); +void check_netif_name(const char *); void sock_error(int); + +extern const struct proto protos[]; +extern const struct aal aals[]; +extern const struct encaps encaps[]; diff --git a/sbin/atm/atm/atm_eni.c b/sbin/atm/atm/atm_eni.c index 8b0627ac8dd..a35196f890b 100644 --- a/sbin/atm/atm/atm_eni.c +++ b/sbin/atm/atm/atm_eni.c @@ -104,6 +104,11 @@ Section Path Line Line Path Corr Uncorr\n\ BIP8 BIP8 BIP24 FEBE FEBE HCS HCS\n\ Errs Errs Errs Errs Errs Errs Errs\n" +static void print_eni_oc3(struct air_vinfo_rsp *); +static void print_eni_atm(struct air_vinfo_rsp *); +static void print_eni_aal0(struct air_vinfo_rsp *); +static void print_eni_aal5(struct air_vinfo_rsp *); +static void print_eni_driver(struct air_vinfo_rsp *); /* * Process show ENI statistics command @@ -177,12 +182,12 @@ show_eni_stats(intf, argc, argv) } exit(1); } - stats = (struct air_vinfo_rsp *) air.air_buf_addr; + stats = (struct air_vinfo_rsp *)(void *)air.air_buf_addr; /* * Print the statistics */ - if (buf_len < sizeof(struct air_vinfo_rsp) + + if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) + sizeof(Eni_stats)) { free(stats); return; diff --git a/sbin/atm/atm/atm_fore200.c b/sbin/atm/atm/atm_fore200.c index 4e821043875..f50451fbd8b 100644 --- a/sbin/atm/atm/atm_fore200.c +++ b/sbin/atm/atm/atm_fore200.c @@ -117,6 +117,14 @@ Section Path Line Line Path Corr Uncorr\n\ BIP8 BIP8 BIP24 FEBE FEBE HCS HCS\n\ Errs Errs Errs Errs Errs Errs Errs\n" +static void print_fore200_taxi(struct air_vinfo_rsp *); +static void print_fore200_oc3(struct air_vinfo_rsp *); +static void print_fore200_dev(struct air_vinfo_rsp *); +static void print_fore200_atm(struct air_vinfo_rsp *); +static void print_fore200_aal0(struct air_vinfo_rsp *); +static void print_fore200_aal4(struct air_vinfo_rsp *); +static void print_fore200_aal5(struct air_vinfo_rsp *); +static void print_fore200_driver(struct air_vinfo_rsp *); /* * Process show Fore SBA-200 statistics command @@ -195,7 +203,7 @@ show_fore200_stats(intf, argc, argv) } exit(1); } - cfg = (struct air_cfg_rsp *) air.air_buf_addr; + cfg = (struct air_cfg_rsp *)(void *)air.air_buf_addr; /* * Get vendor-specific statistics from the kernel @@ -221,12 +229,12 @@ show_fore200_stats(intf, argc, argv) } exit(1); } - stats = (struct air_vinfo_rsp *) air.air_buf_addr; + stats = (struct air_vinfo_rsp *)(void *)air.air_buf_addr; /* * Print the statistics */ - if (buf_len < sizeof(struct air_vinfo_rsp) + + if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) + sizeof(Fore_stats)) { free(stats); free(cfg); diff --git a/sbin/atm/atm/atm_inet.c b/sbin/atm/atm/atm_inet.c index cc80e0c8dc0..34d00f8b15c 100644 --- a/sbin/atm/atm/atm_inet.c +++ b/sbin/atm/atm/atm_inet.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "atm.h" @@ -79,21 +80,18 @@ __RCSID("@(#) $FreeBSD$"); * */ void -ip_pvcadd(argc, argv, cmdp, app, intp) - int argc; - char **argv; - struct cmd *cmdp; - struct atmaddreq *app; - struct air_int_rsp *intp; +ip_pvcadd(int argc, char **argv, const struct cmd *cmdp, + struct atmaddreq *app, struct air_int_rsp *intp) { char *cp; char nhelp[128]; - int i, netif_pref_len, netif_no; + int netif_no; + u_int i, netif_pref_len; /* * Yet more validation */ - if (argc != 2) { + if (argc < 2) { strcpy(nhelp, cmdp->help); cp = strstr(nhelp, ""); if (cp) @@ -112,7 +110,7 @@ ip_pvcadd(argc, argv, cmdp, app, intp) netif_pref_len = strlen(intp->anp_nif_pref); cp = &argv[0][netif_pref_len]; netif_no = atoi(cp); - for (i=0; i '9') { netif_no = -1; break; @@ -152,11 +150,13 @@ ip_pvcadd(argc, argv, cmdp, app, intp) /* * Get destination IP address */ - struct sockaddr_in *sin; + struct sockaddr_in *sain, *ret; - sin = (struct sockaddr_in *) &app->aar_pvc_dst; - sin->sin_addr.s_addr = - get_ip_addr(argv[0])->sin_addr.s_addr; + sain = (struct sockaddr_in *)(void *)&app->aar_pvc_dst; + ret = get_ip_addr(argv[0]); + if (ret == NULL) + errx(1, "%s: bad ip address '%s'", argv[-1], argv[0]); + sain->sin_addr.s_addr = ret->sin_addr.s_addr; } argc--; argv++; } diff --git a/sbin/atm/atm/atm_print.c b/sbin/atm/atm/atm_print.c index a9fcbcfb256..727422ce2c4 100644 --- a/sbin/atm/atm/atm_print.c +++ b/sbin/atm/atm/atm_print.c @@ -99,13 +99,6 @@ Interface VPI VCI PDUs Bytes Errs PDUs Bytes Errs\n" " Input Input Input Output Output Output Cmd\n\ Interface PDUs Bytes Errs PDUs Bytes Errs Errs\n" -/* - * External references - */ -extern struct proto protos[]; -extern struct aal aals[]; -extern struct encaps encaps[]; - /* * Local variables */ @@ -122,7 +115,7 @@ static int version_hdr = 0; /* * SIGPVC state definitions */ -struct state sigpvc_states[] = { +static const struct state sigpvc_states[] = { { "ACTIVE", SIGPVC_ACTIVE }, { "DETACH", SIGPVC_DETACH }, { 0, 0 } @@ -131,7 +124,7 @@ struct state sigpvc_states[] = { /* * SPANS state definitions */ -struct state spans_states[] = { +static const struct state spans_states[] = { { "ACTIVE", SPANS_ACTIVE }, { "DETACH", SPANS_DETACH }, { "INIT", SPANS_INIT }, @@ -142,7 +135,7 @@ struct state spans_states[] = { /* * UNISIG state definitions */ -struct state unisig_states[] = { +static const struct state unisig_states[] = { { "NULL", UNISIG_NULL }, { "ADR_WAIT", UNISIG_ADDR_WAIT }, { "INIT", UNISIG_INIT }, @@ -154,7 +147,7 @@ struct state unisig_states[] = { /* * SIGPVC VCC state definitions */ -struct state sigpvc_vcc_states[] = { +static const struct state sigpvc_vcc_states[] = { { "NULL", VCCS_NULL }, { "ACTIVE", VCCS_ACTIVE }, { "FREE", VCCS_FREE }, @@ -164,7 +157,7 @@ struct state sigpvc_vcc_states[] = { /* * SPANS VCC state definitions */ -struct state spans_vcc_states[] = { +static const struct state spans_vcc_states[] = { { "NULL", SPANS_VC_NULL }, { "ACTIVE", SPANS_VC_ACTIVE }, { "ACT_DOWN", SPANS_VC_ACT_DOWN }, @@ -180,7 +173,7 @@ struct state spans_vcc_states[] = { /* * UNISIG VCC state definitions */ -struct state unisig_vcc_states[] = { +static const struct state unisig_vcc_states[] = { { "NULL", UNI_NULL }, { "C_INIT", UNI_CALL_INITIATED }, { "C_OUT_PR", UNI_CALL_OUT_PROC }, @@ -202,7 +195,7 @@ struct state unisig_vcc_states[] = { /* * IP VCC state definitions */ -struct state ip_vcc_states[] = { +static const struct state ip_vcc_states[] = { { "FREE", IPVCC_FREE }, { "PMAP", IPVCC_PMAP }, { "POPEN", IPVCC_POPEN }, @@ -216,7 +209,7 @@ struct state ip_vcc_states[] = { /* * ARP server state definitions */ -struct state arpserver_states[] = { +static const struct state arpserver_states[] = { { "NOT_CONF", UIAS_NOTCONF }, { "SERVER", UIAS_SERVER_ACTIVE }, { "PEND_ADR", UIAS_CLIENT_PADDR }, @@ -229,7 +222,7 @@ struct state arpserver_states[] = { /* * Supported signalling managers */ -struct proto_state proto_states[] = { +static const struct proto_state proto_states[] = { { "SIGPVC", sigpvc_states, sigpvc_vcc_states, ATM_SIG_PVC }, { "SPANS", spans_states, spans_vcc_states, ATM_SIG_SPANS }, { "UNI 3.0", unisig_states, unisig_vcc_states, ATM_SIG_UNI30 }, @@ -241,7 +234,7 @@ struct proto_state proto_states[] = { /* * ATMARP origin values */ -struct state arp_origins[] = { +static const struct state arp_origins[] = { { "LOCAL", UAO_LOCAL }, { "PERM", UAO_PERM }, { "REG", UAO_REGISTER }, @@ -268,9 +261,9 @@ print_arp_info(ai) struct air_arp_rsp *ai; { int i; - char *atm_addr, *ip_addr, *origin; + const char *atm_addr, *ip_addr, *origin; char age[8], flags[32]; - struct sockaddr_in *sin; + struct sockaddr_in *sain; /* * Print a header if it hasn't been done yet. @@ -284,8 +277,8 @@ print_arp_info(ai) * Format the addresses */ atm_addr = format_atm_addr(&ai->aap_addr); - sin = (struct sockaddr_in *)&ai->aap_arp_addr; - ip_addr = format_ip_addr(&sin->sin_addr); + sain = (struct sockaddr_in *)(void *)&ai->aap_arp_addr; + ip_addr = format_ip_addr(&sain->sin_addr); /* * Decode the flags @@ -348,7 +341,7 @@ print_asrv_info(si) struct air_asrv_rsp *si; { int i; - char *atm_addr, *state; + const char *atm_addr, *state; struct in_addr *addr; /* @@ -418,7 +411,7 @@ void print_cfg_info(si) struct air_cfg_rsp *si; { - char *adapter, *bus, *media, *vendor; + const char *adapter, *bus, *media, *vendor; /* * Print a header if it hasn't been done yet. @@ -474,8 +467,9 @@ print_intf_info(ni) int i; char nif_names[(IFNAMSIZ *2)+4]; char *atm_addr; - char *sigmgr = "-", *state_name = "-"; - struct state *s_t; + const char *sigmgr = "-"; + const char *state_name = "-"; + const struct state *s_t; /* * Print a header @@ -553,9 +547,9 @@ print_ip_vcc_info(ai) struct air_ip_vcc_rsp *ai; { int i; - char *ip_addr, *state; + const char *ip_addr, *state; char flags[32], vpi_vci[16]; - struct sockaddr_in *sin; + struct sockaddr_in *sain; /* * Print a header if it hasn't been done yet. @@ -568,8 +562,8 @@ print_ip_vcc_info(ai) /* * Format the IP address */ - sin = (struct sockaddr_in *)&ai->aip_dst_addr; - ip_addr = format_ip_addr(&sin->sin_addr); + sain = (struct sockaddr_in *)(void *)&ai->aip_dst_addr; + ip_addr = format_ip_addr(&sain->sin_addr); /* * Format the VPI/VCI @@ -638,8 +632,8 @@ void print_netif_info(ni) struct air_netif_rsp *ni; { - char *ip_addr; - struct sockaddr_in *sin; + const char *ip_addr; + struct sockaddr_in *sain; /* * Print a header @@ -652,8 +646,8 @@ print_netif_info(ni) /* * Format the protocol address */ - sin = (struct sockaddr_in *)&ni->anp_proto_addr; - ip_addr = format_ip_addr(&sin->sin_addr); + sain = (struct sockaddr_in *)(void *)&ni->anp_proto_addr; + ip_addr = format_ip_addr(&sain->sin_addr); /* * Print the network interface information @@ -691,14 +685,14 @@ print_intf_stats(pi) * Print the interface statistics */ printf("%-9s %7lld %8lld %5lld %7lld %8lld %5lld %5lld\n", - pi->app_intf, - pi->app_ipdus, - pi->app_ibytes, - pi->app_ierrors, - pi->app_opdus, - pi->app_obytes, - pi->app_oerrors, - pi->app_cmderrors); + pi->app_intf, + (unsigned long long)pi->app_ipdus, + (unsigned long long)pi->app_ibytes, + (unsigned long long)pi->app_ierrors, + (unsigned long long)pi->app_opdus, + (unsigned long long)pi->app_obytes, + (unsigned long long)pi->app_oerrors, + (unsigned long long)pi->app_cmderrors); } @@ -765,10 +759,10 @@ print_vcc_info(vi) struct air_vcc_rsp *vi; { int i; - char *aal_name = "-" , *encaps_name = "-", *owner_name = "-"; - char *state_name = "-", *type_name = "-"; + const char *aal_name = "-" , *encaps_name = "-", *owner_name = "-"; + const char *state_name = "-", *type_name = "-"; char dir_name[10]; - struct state *s_t; + const struct state *s_t; /* * Print a header if it hasn't already been done diff --git a/sbin/atm/atm/atm_set.c b/sbin/atm/atm/atm_set.c index c637827827c..08e8b7a72dc 100644 --- a/sbin/atm/atm/atm_set.c +++ b/sbin/atm/atm/atm_set.c @@ -77,10 +77,7 @@ __RCSID("@(#) $FreeBSD$"); * */ void -set_arpserver(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +set_arpserver(int argc, char **argv, const struct cmd *cmdp __unused) { int i, len, prefix_len = 0, rc, s; char *intf; @@ -164,7 +161,7 @@ set_arpserver(argc, argv, cmdp) exit(1); } int_info = (struct air_netif_rsp *) air.air_buf_addr; - lis = (struct sockaddr_in *)&int_info->anp_proto_addr; + lis = (struct sockaddr_in *)(void *)&int_info->anp_proto_addr; prefix_buf[0].ip_addr = lis->sin_addr; free(int_info); @@ -276,10 +273,7 @@ set_arpserver(argc, argv, cmdp) * */ void -set_macaddr(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +set_macaddr(int argc, char **argv, const struct cmd *cmdp __unused) { int s; char *intf; @@ -372,10 +366,7 @@ set_macaddr(argc, argv, cmdp) * */ void -set_netif(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +set_netif(int argc, char **argv, const struct cmd *cmdp __unused) { struct atmsetreq anr; char str[16]; @@ -460,14 +451,11 @@ set_netif(argc, argv, cmdp) * */ void -set_prefix(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +set_prefix(int argc, char **argv, const struct cmd *cmdp __unused) { int s; char *intf; - u_char prefix[13]; + u_char pfx[13]; struct atmsetreq asr; /* @@ -483,8 +471,7 @@ set_prefix(argc, argv, cmdp) /* * Get the prefix provided by the user */ - if (get_hex_atm_addr(argv[0], prefix, sizeof(prefix)) != - sizeof(prefix)) { + if (get_hex_atm_addr(argv[0], pfx, sizeof(pfx)) != sizeof(pfx)) { fprintf(stderr, "%s: Invalid NSAP prefix\n", prog); exit(1); } @@ -494,7 +481,7 @@ set_prefix(argc, argv, cmdp) */ asr.asr_opcode = AIOCS_SET_PRF; strncpy(asr.asr_prf_intf, intf, sizeof(asr.asr_prf_intf)); - bcopy(prefix, asr.asr_prf_pref, sizeof(asr.asr_prf_pref)); + bcopy(pfx, asr.asr_prf_pref, sizeof(asr.asr_prf_pref)); /* * Pass the new prefix to the kernel diff --git a/sbin/atm/atm/atm_show.c b/sbin/atm/atm/atm_show.c index a6a3bc84ad8..8154fcbf201 100644 --- a/sbin/atm/atm/atm_show.c +++ b/sbin/atm/atm/atm_show.c @@ -84,17 +84,14 @@ static int arp_compare(const void *, const void *); * */ void -show_arp(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_arp(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len, arp_info_len; struct atminfreq air; struct air_arp_rsp *arp_info, *arp_info_base; - struct sockaddr_in *sin; + struct sockaddr_in *sain; union { - struct sockaddr_in sin; + struct sockaddr_in sain; struct sockaddr sa; } host_addr; @@ -104,15 +101,15 @@ show_arp(argc, argv, cmdp) bzero(&host_addr, sizeof(host_addr)); host_addr.sa.sa_family = AF_INET; if (argc) { - sin = get_ip_addr(argv[0]); - if (!sin) { + sain = get_ip_addr(argv[0]); + if (!sain) { fprintf(stderr, "%s: host \'%s\' not found\n", prog, argv[0]); exit(1); } - host_addr.sin.sin_addr.s_addr = sin->sin_addr.s_addr; + host_addr.sain.sin_addr.s_addr = sain->sin_addr.s_addr; } else { - host_addr.sin.sin_addr.s_addr = INADDR_ANY; + host_addr.sain.sin_addr.s_addr = INADDR_ANY; } /* @@ -182,10 +179,7 @@ show_arp(argc, argv, cmdp) * */ void -show_arpserv(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_arpserv(int argc, char **argv, const struct cmd *cmdp __unused) { int asrv_info_len, buf_len = sizeof(struct air_asrv_rsp) * 3; struct atminfreq air; @@ -232,8 +226,8 @@ show_arpserv(argc, argv, cmdp) * Print the interface information */ asrv_info_base = asrv_info = - (struct air_asrv_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_asrv_rsp); + (struct air_asrv_rsp *)(void *)air.air_buf_addr; + for (; (size_t)buf_len >= sizeof(struct air_asrv_rsp); asrv_info = (struct air_asrv_rsp *) ((u_long)asrv_info + asrv_info_len), buf_len -= asrv_info_len) { @@ -262,10 +256,7 @@ show_arpserv(argc, argv, cmdp) * */ void -show_config(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_config(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len = sizeof(struct air_asrv_rsp) * 3; struct atminfreq air; @@ -312,8 +303,8 @@ show_config(argc, argv, cmdp) * Print the interface information */ cfg_info_base = cfg_info = - (struct air_cfg_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_cfg_rsp); cfg_info++, + (struct air_cfg_rsp *)(void *)air.air_buf_addr; + for (; (size_t)buf_len >= sizeof(struct air_cfg_rsp); cfg_info++, buf_len -= sizeof(struct air_cfg_rsp)) { print_cfg_info(cfg_info); } @@ -337,10 +328,7 @@ show_config(argc, argv, cmdp) * */ void -show_intf(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_intf(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len = sizeof(struct air_int_rsp) * 3; struct atminfreq air; @@ -387,8 +375,8 @@ show_intf(argc, argv, cmdp) * Print the interface information */ int_info_base = int_info = - (struct air_int_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_int_rsp); int_info++, + (struct air_int_rsp *)(void *)air.air_buf_addr; + for (; (size_t)buf_len >= sizeof(struct air_int_rsp); int_info++, buf_len -= sizeof(struct air_int_rsp)) { print_intf_info(int_info); } @@ -412,18 +400,15 @@ show_intf(argc, argv, cmdp) * */ void -show_ip_vcc(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_ip_vcc(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len, ip_info_len, rc; char *if_name = (char *)0; struct atminfreq air; struct air_ip_vcc_rsp *ip_info, *ip_info_base; - struct sockaddr_in *sin; + struct sockaddr_in *sain; union { - struct sockaddr_in sin; + struct sockaddr_in sain; struct sockaddr sa; } host_addr; @@ -463,12 +448,12 @@ show_ip_vcc(argc, argv, cmdp) /* * Get IP address of specified host name */ - sin = get_ip_addr(argv[0]); - host_addr.sin.sin_addr.s_addr = - sin->sin_addr.s_addr; + sain = get_ip_addr(argv[0]); + host_addr.sain.sin_addr.s_addr = + sain->sin_addr.s_addr; } } else { - host_addr.sin.sin_addr.s_addr = INADDR_ANY; + host_addr.sain.sin_addr.s_addr = INADDR_ANY; } /* @@ -495,7 +480,7 @@ show_ip_vcc(argc, argv, cmdp) exit(1); } ip_info_base = ip_info = - (struct air_ip_vcc_rsp *) air.air_buf_addr; + (struct air_ip_vcc_rsp *)(void *)air.air_buf_addr; /* * Sort the information @@ -540,10 +525,7 @@ show_ip_vcc(argc, argv, cmdp) * */ void -show_netif(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_netif(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len = sizeof(struct air_netif_rsp) * 3; struct atminfreq air; @@ -590,7 +572,7 @@ show_netif(argc, argv, cmdp) */ int_info_base = int_info = (struct air_netif_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_netif_rsp); int_info++, + for (; (size_t)buf_len >= sizeof(struct air_netif_rsp); int_info++, buf_len -= sizeof(struct air_netif_rsp)) { print_netif_info(int_info); } @@ -614,10 +596,7 @@ show_netif(argc, argv, cmdp) * */ void -show_intf_stats(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_intf_stats(int argc, char **argv, const struct cmd *cmdp __unused) { int buf_len; char intf[IFNAMSIZ]; @@ -668,7 +647,7 @@ show_intf_stats(argc, argv, cmdp) } exit(1); } - cfg_info = (struct air_cfg_rsp *)air.air_buf_addr; + cfg_info = (struct air_cfg_rsp *)(void *)air.air_buf_addr; /* * Call the appropriate vendor-specific routine @@ -716,9 +695,9 @@ show_intf_stats(argc, argv, cmdp) /* * Display the interface statistics */ - pstat_info_base = pstat_info = - (struct air_phy_stat_rsp *)air.air_buf_addr; - for (; buf_len >= sizeof(struct air_phy_stat_rsp); + pstat_info_base = pstat_info = (struct air_phy_stat_rsp *) + (void *)air.air_buf_addr; + for (; (size_t)buf_len >= sizeof(struct air_phy_stat_rsp); pstat_info++, buf_len-=sizeof(struct air_phy_stat_rsp)) { print_intf_stats(pstat_info); @@ -744,10 +723,7 @@ show_intf_stats(argc, argv, cmdp) * */ void -show_vcc_stats(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_vcc_stats(int argc, char **argv, const struct cmd *cmdp __unused) { int vcc_info_len; int vpi = -1, vci = -1; @@ -827,7 +803,7 @@ show_vcc_stats(argc, argv, cmdp) * Display the VCC statistics */ vcc_info_base = vcc_info; - for (; vcc_info_len >= sizeof(struct air_vcc_rsp); + for (; (size_t)vcc_info_len >= sizeof(struct air_vcc_rsp); vcc_info_len-=sizeof(struct air_vcc_rsp), vcc_info++) { if (vpi != -1 && vcc_info->avp_vpi != vpi) @@ -856,10 +832,7 @@ show_vcc_stats(argc, argv, cmdp) * */ void -show_vcc(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_vcc(int argc, char **argv, const struct cmd *cmdp __unused) { int vcc_info_len; int vpi = -1, vci = -1, show_pvc = 0, show_svc = 0; @@ -946,7 +919,7 @@ show_vcc(argc, argv, cmdp) * Display the VCC information */ vcc_info_base = vcc_info; - for (; vcc_info_len >= sizeof(struct air_vcc_rsp); + for (; (size_t)vcc_info_len >= sizeof(struct air_vcc_rsp); vcc_info_len-=sizeof(struct air_vcc_rsp), vcc_info++) { if (vpi != -1 && vcc_info->avp_vpi != vpi) @@ -979,10 +952,8 @@ show_vcc(argc, argv, cmdp) * */ void -show_version(argc, argv, cmdp) - int argc; - char **argv; - struct cmd *cmdp; +show_version(int argc __unused, char **argv __unused, + const struct cmd *cmdp __unused) { int buf_len = sizeof(struct air_version_rsp); struct atminfreq air; @@ -1014,8 +985,8 @@ show_version(argc, argv, cmdp) * Print the network interface information */ ver_info_base = ver_info = - (struct air_version_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_version_rsp); ver_info++, + (struct air_version_rsp *)(void *)air.air_buf_addr; + for (; (size_t)buf_len >= sizeof(struct air_version_rsp); ver_info++, buf_len -= sizeof(struct air_version_rsp)) { print_version_info(ver_info); } @@ -1041,10 +1012,10 @@ vcc_compare(p1, p2) const void *p1, *p2; { int rc; - struct air_vcc_rsp *c1, *c2; + const struct air_vcc_rsp *c1, *c2; - c1 = (struct air_vcc_rsp *) p1; - c2 = (struct air_vcc_rsp *) p2; + c1 = (const struct air_vcc_rsp *) p1; + c2 = (const struct air_vcc_rsp *) p2; /* * Compare the interface names @@ -1093,10 +1064,10 @@ ip_vcc_compare(p1, p2) const void *p1, *p2; { int rc; - struct air_ip_vcc_rsp *c1, *c2; + const struct air_ip_vcc_rsp *c1, *c2; - c1 = (struct air_ip_vcc_rsp *) p1; - c2 = (struct air_ip_vcc_rsp *) p2; + c1 = (const struct air_ip_vcc_rsp *) p1; + c2 = (const struct air_ip_vcc_rsp *) p2; /* * Compare the interface names @@ -1138,13 +1109,13 @@ arp_compare(p1, p2) const void *p1, *p2; { int rc; - struct air_arp_rsp *c1, *c2; - struct sockaddr_in *sin1, *sin2; + const struct air_arp_rsp *c1, *c2; + const struct sockaddr_in *sin1, *sin2; - c1 = (struct air_arp_rsp *) p1; - c2 = (struct air_arp_rsp *) p2; - sin1 = (struct sockaddr_in *) &c1->aap_arp_addr; - sin2 = (struct sockaddr_in *) &c2->aap_arp_addr; + c1 = (const struct air_arp_rsp *)p1; + c2 = (const struct air_arp_rsp *)p2; + sin1 = (const struct sockaddr_in *)(const void *)&c1->aap_arp_addr; + sin2 = (const struct sockaddr_in *)(const void *)&c2->aap_arp_addr; /* * Compare the IP addresses @@ -1166,19 +1137,16 @@ arp_compare(p1, p2) rc = 0; break; case T_ATM_ENDSYS_ADDR: - rc = bcmp((caddr_t)c1->aap_addr.address, - (caddr_t)c2->aap_addr.address, - sizeof(Atm_addr_nsap)); + rc = bcmp(c1->aap_addr.address, c2->aap_addr.address, + sizeof(Atm_addr_nsap)); break; case T_ATM_E164_ADDR: - rc = bcmp((caddr_t)c1->aap_addr.address, - (caddr_t)c2->aap_addr.address, - sizeof(Atm_addr_e164)); + rc = bcmp(c1->aap_addr.address, c2->aap_addr.address, + sizeof(Atm_addr_e164)); break; case T_ATM_SPANS_ADDR: - rc = bcmp((caddr_t)c1->aap_addr.address, - (caddr_t)c2->aap_addr.address, - sizeof(Atm_addr_spans)); + rc = bcmp(c1->aap_addr.address, c2->aap_addr.address, + sizeof(Atm_addr_spans)); break; } diff --git a/sbin/atm/atm/atm_subr.c b/sbin/atm/atm/atm_subr.c index eaac8320c58..df6c081cd04 100644 --- a/sbin/atm/atm/atm_subr.c +++ b/sbin/atm/atm/atm_subr.c @@ -65,18 +65,20 @@ __RCSID("@(#) $FreeBSD$"); */ typedef struct { int type; - char *name; + const char *name; } tbl_ent; /* * Table to translate vendor codes to ASCII */ -tbl_ent vendors[] = { - { VENDAPI_UNKNOWN, "Unknown" }, - { VENDAPI_FORE_1, "Fore" }, - { VENDAPI_ENI_1, "ENI" }, - { VENDAPI_IDT_1, "IDT" }, +static const tbl_ent vendors[] = { + { VENDOR_UNKNOWN, "Unknown" }, + { VENDOR_FORE, "Fore" }, + { VENDOR_ENI, "ENI" }, + { VENDOR_IDT, "IDT" }, + { VENDOR_PROSUM, "ProSum" }, + { VENDOR_NETGRAPH, "Netgraph" }, { 0, 0 }, }; @@ -84,7 +86,7 @@ tbl_ent vendors[] = { /* * Table to translate adapter codes to ASCII */ -tbl_ent adapter_types[] = { +static const tbl_ent adapter_types[] = { { DEV_UNKNOWN, "Unknown" }, { DEV_FORE_SBA200E, "SBA-200E" }, { DEV_FORE_SBA200, "SBA-200" }, @@ -92,31 +94,46 @@ tbl_ent adapter_types[] = { { DEV_FORE_ESA200E, "ESA-200E" }, { DEV_ENI_155P, "ENI-155p" }, { DEV_IDT_155, "IDT" }, + { DEV_PROATM_25, "PROATM-25" }, + { DEV_PROATM_155, "PROATM-155" }, + { DEV_VATMPIF, "VATMPIF" }, + { DEV_FORE_LE25, "ForeLE-25" }, + { DEV_FORE_LE155, "ForeLE-155" }, + { DEV_IDT_25, "NICStAR-25" }, + { DEV_IDTABR_25, "IDT77252-25" }, + { DEV_IDTABR_155, "IDT77252-155" }, + { DEV_FORE_HE155, "ForeHE-155" }, + { DEV_FORE_HE622, "ForeHE-622" }, { 0, 0 }, }; /* * Table to translate medium types to ASCII */ -tbl_ent media_types[] = { +static const tbl_ent media_types[] = { { MEDIA_UNKNOWN, "Unknown" }, { MEDIA_TAXI_100, "100 Mbps 4B/5B" }, { MEDIA_TAXI_140, "140 Mbps 4B/5B" }, { MEDIA_OC3C, "OC-3c" }, { MEDIA_OC12C, "OC-12c" }, { MEDIA_UTP155, "155 Mbps UTP" }, + { MEDIA_UTP25, "25.6 Mbps UTP" }, + { MEDIA_VIRTUAL, "Virtual Link" }, + { MEDIA_DSL, "xDSL" }, { 0, 0 }, }; /* * Table to translate bus types to ASCII */ -tbl_ent bus_types[] = { +static const tbl_ent bus_types[] = { { BUS_UNKNOWN, "Unknown" }, { BUS_SBUS_B16, "SBus" }, { BUS_SBUS_B32, "SBus" }, { BUS_PCI, "PCI" }, { BUS_EISA, "EISA" }, + { BUS_USB, "USB" }, + { BUS_VIRTUAL, "Virtual" }, { 0, 0 }, }; @@ -133,9 +150,8 @@ tbl_ent bus_types[] = { * char * pointer to a string with the vendor name * */ -char * -get_vendor(vendor) - int vendor; +const char * +get_vendor(int vendor) { int i; @@ -158,9 +174,8 @@ get_vendor(vendor) * char * pointer to a string with the adapter type * */ -char * -get_adapter(dev) - int dev; +const char * +get_adapter(int dev) { int i; @@ -183,9 +198,8 @@ get_adapter(dev) * char * pointer to a string with the name of the medium * */ -char * -get_media_type(media) - int media; +const char * +get_media_type(int media) { int i; @@ -208,9 +222,8 @@ get_media_type(media) * char * pointer to a string with the bus type * */ -char * -get_bus_type(bus) - int bus; +const char * +get_bus_type(int bus) { int i; @@ -235,9 +248,8 @@ get_bus_type(bus) * char * pointer to a string identifying the adapter * */ -char * -get_adapter_name(intf) - char *intf; +const char * +get_adapter_name(const char *intf) { int buf_len; struct atminfreq air; @@ -256,9 +268,9 @@ get_adapter_name(intf) air.air_opcode = AIOCS_INF_CFG; strcpy(air.air_cfg_intf, intf); buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp)); - if (buf_len < sizeof(struct air_cfg_rsp)) + if ((size_t)buf_len < sizeof(struct air_cfg_rsp)) return("-"); - cfg = (struct air_cfg_rsp *) air.air_buf_addr; + cfg = (struct air_cfg_rsp *)(void *)air.air_buf_addr; /* * Build a string describing the adapter @@ -283,9 +295,8 @@ get_adapter_name(intf) * the address of a string representing the MAC address * */ -char * -format_mac_addr(addr) - Mac_addr *addr; +const char * +format_mac_addr(const Mac_addr *addr) { static char str[256]; @@ -328,9 +339,7 @@ format_mac_addr(addr) * */ int -parse_ip_prefix(cp, op) - char *cp; - struct in_addr *op; +parse_ip_prefix(const char *cp, struct in_addr *op) { int len; char *mp; @@ -385,7 +394,7 @@ parse_ip_prefix(cp, op) * Convert the IP-address part of the prefix */ ip_addr.s_addr = inet_addr(cp); - if (ip_addr.s_addr == -1) + if (ip_addr.s_addr == INADDR_NONE) return(-1); /* @@ -432,9 +441,7 @@ parse_ip_prefix(cp, op) * */ int -compress_prefix_list(ipp, ilen) - struct in_addr *ipp; - int ilen; +compress_prefix_list(struct in_addr *ipp, int ilen) { int i, j, n; struct in_addr *ip1, *ip2, *m1, *m2; @@ -543,15 +550,14 @@ compress_prefix_list(ipp, ilen) * */ void -check_netif_name(nif) - char *nif; +check_netif_name(const char *nif) { int rc; /* * Look up the name in the kernel */ - rc = verify_nif_name(nif); + rc = verify_nif_name(__DECONST(char *, nif)); /* XXX */ /* * Check the result @@ -604,8 +610,7 @@ check_netif_name(nif) * */ void -sock_error(err) - int err; +sock_error(int err) { fprintf(stderr, "%s: ", prog); -- 2.45.2