From 2a19b516babaa7a82615cfc1637c433ee7e84888 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Mon, 16 Oct 2006 00:15:35 +0000 Subject: [PATCH] WARNS6 cleanups. Add static and const where appropriate. ANSI function declarations. Rename variables that shadow variables higher in scope. --- sbin/atm/atm/atm.c | 122 +++++++++--------- sbin/atm/atm/atm.h | 100 ++++++--------- sbin/atm/atm/atm_eni.c | 20 +-- sbin/atm/atm/atm_fore200.c | 28 +++-- sbin/atm/atm/atm_inet.c | 7 +- sbin/atm/atm/atm_print.c | 44 +++---- sbin/atm/atm/atm_set.c | 18 +-- sbin/atm/atm/atm_show.c | 75 ++++++------ sbin/atm/atm/atm_subr.c | 28 ++--- sbin/atm/fore_dnld/fore_dnld.c | 91 +++++++------- sbin/atm/ilmid/ilmid.c | 217 +++++++++++++-------------------- 11 files changed, 343 insertions(+), 407 deletions(-) diff --git a/sbin/atm/atm/atm.c b/sbin/atm/atm/atm.c index 3ee65e7774..ba907f8c1b 100644 --- a/sbin/atm/atm/atm.c +++ b/sbin/atm/atm/atm.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm.c,v 1.4 2004/12/18 21:43:38 swildner Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -99,37 +99,32 @@ 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 }, - { "attach", 2, 2, attach, " " }, - { "delete", 0, 0, NULL, (char *) dlt_subcmd }, - { "detach", 1, 1, detach, "" }, - { "set", 0, 0, NULL, (char *) set_subcmd }, - { "show", 0, 0, NULL, (char *) show_subcmd }, - { "help", 0, 99, help, "" }, - { 0, 0, 0, NULL, "" } -}; - -struct cmd 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 pvc_add(int, char **, const struct cmd *); +static void arp_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 vcc_dlt(int, char **, const struct cmd *, struct atmdelreq *); +static void arp_dlt(int, char **, const struct cmd *); +static void help(int, char **, const struct cmd *); + +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, " " }, @@ -137,22 +132,33 @@ struct cmd set_subcmd[] = { { 0, 0, 0, NULL, ""} }; -struct cmd show_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, "" } +}; + +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[] = { - { "interface", 0, 2, show_intf_stats, "[ [cfg | phy | dev | atm | aal0 | aal4 | aal5 | driver]]" }, - { "vcc", 0, 3, show_vcc_stats, "[ [vpi [vci]]]" }, +static const struct cmd cmds[] = { + { "add", 0, 0, NULL, (const char *) add_subcmd }, + { "attach", 2, 2, attach, " " }, + { "delete", 0, 0, NULL, (const char *) dlt_subcmd }, + { "detach", 1, 1, detach, "" }, + { "set", 0, 0, NULL, (const char *) set_subcmd }, + { "show", 0, 0, NULL, (const char *) show_subcmd }, + { "help", 0, 99, help, "" }, { 0, 0, 0, NULL, "" } }; @@ -160,7 +166,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 }, @@ -172,7 +178,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 }, @@ -183,7 +189,7 @@ struct owner owners[] = { /* * Supported AAL parameters */ -struct aal aals[] = { +const struct aal aals[] = { { "Null", ATM_AAL0 }, { "AAL0", ATM_AAL0 }, { "AAL1", ATM_AAL1 }, @@ -198,7 +204,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 }, @@ -253,10 +259,10 @@ main(int argc, char **argv) * none * */ -int -do_cmd(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 @@ -299,7 +305,7 @@ do_cmd(struct cmd *descp, int argc, char **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 *)cmdp->help, argc, argv)); } /* @@ -332,8 +338,8 @@ do_cmd(struct cmd *descp, int argc, char **argv) * none * */ -void -usage(struct cmd *cmdp, char *pref) +static void +usage(__unused const struct cmd *cmdp, __unused const char *pref) { fprintf(stderr, "usage: %s command [arg] [arg]...\n", prog); fprintf(stderr, USAGE_STR); @@ -355,11 +361,11 @@ usage(struct cmd *cmdp, char *pref) * none * */ -void -attach(int argc, char **argv, struct cmd *cmdp) +static void +attach(__unused int argc, char **argv, __unused const struct cmd *cmdp) { struct atmcfgreq aar; - struct proto *prp; + const struct proto *prp; int s; /* @@ -451,8 +457,8 @@ attach(int argc, char **argv, struct cmd *cmdp) * none * */ -void -detach(int argc, char **argv, struct cmd *cmdp) +static void +detach(__unused int argc, char **argv, __unused const struct cmd *cmdp) { struct atmcfgreq adr; int s; @@ -517,15 +523,15 @@ detach(int argc, char **argv, struct cmd *cmdp) * none * */ -void -pvc_add(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; @@ -698,8 +704,8 @@ pvc_add(int argc, char **argv, struct cmd *cmdp) * none * */ -void -arp_add(int argc, char **argv, struct cmd *cmdp) +static void +arp_add(int argc, char **argv, __unused const struct cmd *cmdp) { int len, s; struct atmaddreq apr; @@ -804,8 +810,8 @@ arp_add(int argc, char **argv, struct cmd *cmdp) * none * */ -void -pvc_dlt(int argc, char **argv, struct cmd *cmdp) +static void +pvc_dlt(int argc, char **argv, const struct cmd *cmdp) { struct atmdelreq apr; @@ -836,8 +842,8 @@ pvc_dlt(int argc, char **argv, struct cmd *cmdp) * none * */ -void -svc_dlt(int argc, char **argv, struct cmd *cmdp) +static void +svc_dlt(int argc, char **argv, const struct cmd *cmdp) { struct atmdelreq apr; @@ -866,8 +872,8 @@ svc_dlt(int argc, char **argv, struct cmd *cmdp) * none * */ -void -vcc_dlt(int argc, char **argv, struct cmd *cmdp, struct atmdelreq *apr) +static void +vcc_dlt(int argc, char **argv, __unused const struct cmd *cmdp, struct atmdelreq *apr) { char *cp; long v; @@ -953,8 +959,8 @@ vcc_dlt(int argc, char **argv, struct cmd *cmdp, struct atmdelreq *apr) * none * */ -void -arp_dlt(int argc, char **argv, struct cmd *cmdp) +static void +arp_dlt(int argc, char **argv, __unused const struct cmd *cmdp) { int s; struct atmdelreq apr; @@ -1026,8 +1032,8 @@ arp_dlt(int argc, char **argv, struct cmd *cmdp) * none * */ -void -help(int argc, char **argv, struct cmd *cmdp) +static void +help(__unused int argc, __unused char **argv, __unused const struct cmd *cmdp) { usage(cmds, ""); } diff --git a/sbin/atm/atm/atm.h b/sbin/atm/atm/atm.h index f91348a0b9..4537b69427 100644 --- a/sbin/atm/atm/atm.h +++ b/sbin/atm/atm/atm.h @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm.h,v 1.4 1999/08/28 00:12:17 peter Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm.h,v 1.4 2003/11/03 19:51:04 eirikn Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm.h,v 1.5 2006/10/16 00:15:35 pavalos Exp $ * */ @@ -51,12 +51,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 */ + (int, char **, const struct cmd *); + const char *help; /* User help string */ }; @@ -64,7 +64,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 */ }; @@ -73,7 +73,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 */ }; @@ -82,9 +82,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 */ }; @@ -93,10 +93,10 @@ 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 */ - (int, char **, struct cmd *, struct atmaddreq *, + (int, char **, const struct cmd *, struct atmaddreq *, struct air_int_rsp *); }; @@ -105,7 +105,7 @@ struct owner { * Supported AALs */ struct aal { - char *a_name; /* AAL name */ + const char *a_name; /* AAL name */ u_char a_id; /* AAL code */ }; @@ -114,7 +114,7 @@ struct aal { * Supported encapsulations */ struct encaps { - char *e_name; /* Encapsulation name */ + const char *e_name; /* Encapsulation name */ u_char e_id; /* Encapsulation code */ }; @@ -128,40 +128,15 @@ 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 (int, char **, struct cmd *, struct atmaddreq *, +void ip_pvcadd (int, char **, const struct cmd *, struct atmaddreq *, struct air_int_rsp *); /* atm_print.c */ @@ -177,37 +152,30 @@ 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_intf_stats(int, char **, const struct cmd *); +void show_vcc_stats(int, char **, const struct cmd *); +void show_vcc(int, char **, const struct cmd *); +void show_version(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 *); -int get_hex_addr(char *, u_char *, int); -char * format_mac_addr(Mac_addr *); +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_adapter_name(char *); +const char * format_mac_addr(Mac_addr *); int parse_ip_prefix(char *, struct in_addr *); int compress_prefix_list(struct in_addr *, int); void check_netif_name(char *); diff --git a/sbin/atm/atm/atm_eni.c b/sbin/atm/atm/atm_eni.c index a9a6a4cdf7..d6c32a36eb 100644 --- a/sbin/atm/atm/atm_eni.c +++ b/sbin/atm/atm/atm_eni.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_eni.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_eni.c,v 1.4 2003/09/28 14:39:16 hmp Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_eni.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -100,6 +100,12 @@ 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 * @@ -174,7 +180,7 @@ show_eni_stats(char *intf, int argc, char **argv) /* * Print the statistics */ - if (buf_len < sizeof(struct air_vinfo_rsp) + + if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) + sizeof(Eni_stats)) { UM_FREE(stats); return; @@ -212,7 +218,7 @@ show_eni_stats(char *intf, int argc, char **argv) * none * */ -void +static void print_eni_oc3(struct air_vinfo_rsp *vi) { Eni_stats *stats; @@ -252,7 +258,7 @@ print_eni_oc3(struct air_vinfo_rsp *vi) * none * */ -void +static void print_eni_atm(struct air_vinfo_rsp *vi) { Eni_stats *stats; @@ -287,7 +293,7 @@ print_eni_atm(struct air_vinfo_rsp *vi) * none * */ -void +static void print_eni_aal0(struct air_vinfo_rsp *vi) { Eni_stats *stats; @@ -323,7 +329,7 @@ print_eni_aal0(struct air_vinfo_rsp *vi) * none * */ -void +static void print_eni_aal5(struct air_vinfo_rsp *vi) { Eni_stats *stats; @@ -364,7 +370,7 @@ print_eni_aal5(struct air_vinfo_rsp *vi) * none * */ -void +static void print_eni_driver(struct air_vinfo_rsp *vi) { Eni_stats *stats; diff --git a/sbin/atm/atm/atm_fore200.c b/sbin/atm/atm/atm_fore200.c index 031e28af98..e5b78921b6 100644 --- a/sbin/atm/atm/atm_fore200.c +++ b/sbin/atm/atm/atm_fore200.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_fore200.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_fore200.c,v 1.4 2003/09/28 14:39:16 hmp Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_fore200.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -112,6 +112,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 @@ -218,7 +226,7 @@ show_fore200_stats(char *intf, int argc, char **argv) /* * Print the statistics */ - if (buf_len < sizeof(struct air_vinfo_rsp) + + if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) + sizeof(Fore_stats)) { UM_FREE(stats); UM_FREE(cfg); @@ -276,7 +284,7 @@ show_fore200_stats(char *intf, int argc, char **argv) * none * */ -void +static void print_fore200_taxi(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -311,7 +319,7 @@ print_fore200_taxi(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_oc3(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -351,7 +359,7 @@ print_fore200_oc3(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_dev(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -390,7 +398,7 @@ print_fore200_dev(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_atm(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -429,7 +437,7 @@ print_fore200_atm(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_aal0(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -465,7 +473,7 @@ print_fore200_aal0(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_aal4(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -507,7 +515,7 @@ print_fore200_aal4(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_aal5(struct air_vinfo_rsp *vi) { Fore_stats *stats; @@ -549,7 +557,7 @@ print_fore200_aal5(struct air_vinfo_rsp *vi) * none * */ -void +static void print_fore200_driver(struct air_vinfo_rsp *vi) { Fore_stats *stats; diff --git a/sbin/atm/atm/atm_inet.c b/sbin/atm/atm/atm_inet.c index f462f9460d..6015da2f07 100644 --- a/sbin/atm/atm/atm_inet.c +++ b/sbin/atm/atm/atm_inet.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_inet.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_inet.c,v 1.3 2003/09/28 14:39:16 hmp Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_inet.c,v 1.4 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -74,12 +74,13 @@ * */ void -ip_pvcadd(int argc, char **argv, struct cmd *cmdp, struct atmaddreq *app, +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; + unsigned int i, netif_pref_len; /* * Yet more validation diff --git a/sbin/atm/atm/atm_print.c b/sbin/atm/atm/atm_print.c index d53421936a..4133f94220 100644 --- a/sbin/atm/atm/atm_print.c +++ b/sbin/atm/atm/atm_print.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_print.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_print.c,v 1.4 2005/11/06 12:06:03 swildner Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_print.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -117,7 +117,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 } @@ -126,7 +126,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 }, @@ -137,7 +137,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 }, @@ -149,7 +149,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 }, @@ -159,7 +159,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 }, @@ -175,7 +175,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 }, @@ -197,7 +197,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 }, @@ -211,7 +211,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 }, @@ -224,7 +224,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 }, @@ -236,7 +236,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 }, @@ -262,7 +262,7 @@ void print_arp_info(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; @@ -341,7 +341,7 @@ void print_asrv_info(struct air_asrv_rsp *si) { int i; - char *atm_addr, *state; + const char *atm_addr, *state; struct in_addr *addr; /* @@ -387,7 +387,7 @@ print_asrv_info(struct air_asrv_rsp *si) for (i = 0; i < si->asp_nprefix; i++) { printf("%s", inet_ntoa(*addr)); addr++; - printf("/0x%0lx", ntohl(addr->s_addr)); + printf("/0x%0lx", (unsigned long)ntohl(addr->s_addr)); addr++; if (i < si->asp_nprefix -1) printf(", "); @@ -410,7 +410,7 @@ print_asrv_info(struct air_asrv_rsp *si) void print_cfg_info(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. @@ -465,8 +465,8 @@ print_intf_info(struct air_int_rsp *ni) int i; char nif_names[(IFNAMSIZ *2)+4]; char *atm_addr; - char *sigmgr = "-", *state_name = "-"; - struct state *s_t; + const char *sigmgr = "-", *state_name = "-"; + const struct state *s_t; /* * Print a header @@ -543,7 +543,7 @@ void print_ip_vcc_info(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; @@ -627,7 +627,7 @@ print_ip_vcc_info(struct air_ip_vcc_rsp *ai) void print_netif_info(struct air_netif_rsp *ni) { - char *ip_addr; + const char *ip_addr; struct sockaddr_in *sin; /* @@ -751,10 +751,10 @@ void print_vcc_info(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 ee9cef4222..8a2c8e45f8 100644 --- a/sbin/atm/atm/atm_set.c +++ b/sbin/atm/atm/atm_set.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_set.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_set.c,v 1.5 2006/08/03 16:40:46 swildner Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_set.c,v 1.6 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -72,7 +72,7 @@ * */ void -set_arpserver(int argc, char **argv, struct cmd *cmdp) +set_arpserver(int argc, char **argv, __unused const struct cmd *cmdp) { int i, len, prefix_len = 0, rc, s; char *intf; @@ -268,7 +268,7 @@ set_arpserver(int argc, char **argv, struct cmd *cmdp) * */ void -set_macaddr(int argc, char **argv, struct cmd *cmdp) +set_macaddr(int argc, char **argv, __unused const struct cmd *cmdp) { int s; char *intf; @@ -361,7 +361,7 @@ set_macaddr(int argc, char **argv, struct cmd *cmdp) * */ void -set_netif(int argc, char **argv, struct cmd *cmdp) +set_netif(int argc, char **argv, __unused const struct cmd *cmdp) { struct atmsetreq anr; char str[16]; @@ -446,11 +446,11 @@ set_netif(int argc, char **argv, struct cmd *cmdp) * */ void -set_prefix(int argc, char **argv, struct cmd *cmdp) +set_prefix(int argc, char **argv, __unused const struct cmd *cmdp) { int s; char *intf; - u_char prefix[13]; + u_char pfix[13]; struct atmsetreq asr; /* @@ -466,8 +466,8 @@ set_prefix(int argc, char **argv, struct cmd *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], pfix, sizeof(pfix)) != + sizeof(pfix)) { fprintf(stderr, "%s: Invalid NSAP prefix\n", prog); exit(1); } @@ -477,7 +477,7 @@ set_prefix(int argc, char **argv, struct cmd *cmdp) */ asr.asr_opcode = AIOCS_SET_PRF; strncpy(asr.asr_prf_intf, intf, sizeof(asr.asr_prf_intf)); - UM_COPY(prefix, asr.asr_prf_pref, sizeof(asr.asr_prf_pref)); + UM_COPY(pfix, 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 c8c2c3a00f..7ee3a60688 100644 --- a/sbin/atm/atm/atm_show.c +++ b/sbin/atm/atm/atm_show.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_show.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_show.c,v 1.4 2003/11/01 17:15:57 drhodus Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_show.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -79,7 +79,7 @@ static int arp_compare(const void *, const void *); * */ void -show_arp(int argc, char **argv, struct cmd *cmdp) +show_arp(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len, arp_info_len; struct atminfreq air; @@ -174,7 +174,7 @@ show_arp(int argc, char **argv, struct cmd *cmdp) * */ void -show_arpserv(int argc, char **argv, struct cmd *cmdp) +show_arpserv(int argc, char **argv, __unused const struct cmd *cmdp) { int asrv_info_len, buf_len = sizeof(struct air_asrv_rsp) * 3; struct atminfreq air; @@ -222,7 +222,7 @@ show_arpserv(int argc, char **argv, struct cmd *cmdp) */ asrv_info_base = asrv_info = (struct air_asrv_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_asrv_rsp); + 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) { @@ -251,7 +251,7 @@ show_arpserv(int argc, char **argv, struct cmd *cmdp) * */ void -show_config(int argc, char **argv, struct cmd *cmdp) +show_config(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len = sizeof(struct air_asrv_rsp) * 3; struct atminfreq air; @@ -299,7 +299,7 @@ show_config(int argc, char **argv, struct cmd *cmdp) */ cfg_info_base = cfg_info = (struct air_cfg_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_cfg_rsp); cfg_info++, + for (; (size_t)buf_len >= sizeof(struct air_cfg_rsp); cfg_info++, buf_len -= sizeof(struct air_cfg_rsp)) { print_cfg_info(cfg_info); } @@ -323,7 +323,7 @@ show_config(int argc, char **argv, struct cmd *cmdp) * */ void -show_intf(int argc, char **argv, struct cmd *cmdp) +show_intf(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len = sizeof(struct air_int_rsp) * 3; struct atminfreq air; @@ -371,7 +371,7 @@ show_intf(int argc, char **argv, struct cmd *cmdp) */ int_info_base = int_info = (struct air_int_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_int_rsp); int_info++, + for (; (size_t)buf_len >= sizeof(struct air_int_rsp); int_info++, buf_len -= sizeof(struct air_int_rsp)) { print_intf_info(int_info); } @@ -395,7 +395,7 @@ show_intf(int argc, char **argv, struct cmd *cmdp) * */ void -show_ip_vcc(int argc, char **argv, struct cmd *cmdp) +show_ip_vcc(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len, ip_info_len, rc; char *if_name = (char *)0; @@ -520,7 +520,7 @@ show_ip_vcc(int argc, char **argv, struct cmd *cmdp) * */ void -show_netif(int argc, char **argv, struct cmd *cmdp) +show_netif(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len = sizeof(struct air_netif_rsp) * 3; struct atminfreq air; @@ -567,7 +567,7 @@ show_netif(int argc, char **argv, struct cmd *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); } @@ -591,7 +591,7 @@ show_netif(int argc, char **argv, struct cmd *cmdp) * */ void -show_intf_stats(int argc, char **argv, struct cmd *cmdp) +show_intf_stats(int argc, char **argv, __unused const struct cmd *cmdp) { int buf_len; char intf[IFNAMSIZ]; @@ -692,7 +692,7 @@ show_intf_stats(int argc, char **argv, struct cmd *cmdp) */ pstat_info_base = pstat_info = (struct air_phy_stat_rsp *)air.air_buf_addr; - for (; buf_len >= sizeof(struct air_phy_stat_rsp); + 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); @@ -718,7 +718,7 @@ show_intf_stats(int argc, char **argv, struct cmd *cmdp) * */ void -show_vcc_stats(int argc, char **argv, struct cmd *cmdp) +show_vcc_stats(int argc, char **argv, __unused const struct cmd *cmdp) { int vcc_info_len; int vpi = -1, vci = -1; @@ -798,7 +798,7 @@ show_vcc_stats(int argc, char **argv, struct cmd *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) @@ -827,7 +827,7 @@ show_vcc_stats(int argc, char **argv, struct cmd *cmdp) * */ void -show_vcc(int argc, char **argv, struct cmd *cmdp) +show_vcc(int argc, char **argv, __unused const struct cmd *cmdp) { int vcc_info_len; int vpi = -1, vci = -1, show_pvc = 0, show_svc = 0; @@ -914,7 +914,7 @@ show_vcc(int argc, char **argv, struct cmd *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) @@ -947,7 +947,8 @@ show_vcc(int argc, char **argv, struct cmd *cmdp) * */ void -show_version(int argc, char **argv, struct cmd *cmdp) +show_version(__unused int argc, __unused char **argv, + __unused const struct cmd *cmdp) { int buf_len = sizeof(struct air_version_rsp); struct atminfreq air; @@ -980,7 +981,7 @@ show_version(int argc, char **argv, struct cmd *cmdp) */ ver_info_base = ver_info = (struct air_version_rsp *) air.air_buf_addr; - for (; buf_len >= sizeof(struct air_version_rsp); ver_info++, + for (; (size_t)buf_len >= sizeof(struct air_version_rsp); ver_info++, buf_len -= sizeof(struct air_version_rsp)) { print_version_info(ver_info); } @@ -1005,10 +1006,10 @@ static int vcc_compare(const void *p1, const void *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 @@ -1056,10 +1057,10 @@ static int ip_vcc_compare(const void *p1, const void *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 @@ -1100,13 +1101,13 @@ static int arp_compare(const void *p1, const void *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 *) &c1->aap_arp_addr; + sin2 = (const struct sockaddr_in *) &c2->aap_arp_addr; /* * Compare the IP addresses @@ -1128,18 +1129,18 @@ arp_compare(const void *p1, const void *p2) rc = 0; break; case T_ATM_ENDSYS_ADDR: - rc = bcmp((caddr_t)c1->aap_addr.address, - (caddr_t)c2->aap_addr.address, + 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, + 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, + 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 749c252a2f..5779971110 100644 --- a/sbin/atm/atm/atm_subr.c +++ b/sbin/atm/atm/atm_subr.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/atm/atm_subr.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $ - * @(#) $DragonFly: src/sbin/atm/atm/atm_subr.c,v 1.3 2003/09/28 14:39:16 hmp Exp $ + * @(#) $DragonFly: src/sbin/atm/atm/atm_subr.c,v 1.4 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -60,14 +60,14 @@ */ typedef struct { int type; - char *name; + const char *name; } tbl_ent; /* * Table to translate vendor codes to ASCII */ -tbl_ent vendors[] = { +static const tbl_ent vendors[] = { { VENDAPI_UNKNOWN, "Unknown" }, { VENDAPI_FORE_1, "Fore" }, { VENDAPI_ENI_1, "ENI" }, @@ -78,7 +78,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" }, @@ -90,7 +90,7 @@ tbl_ent adapter_types[] = { /* * 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" }, @@ -103,7 +103,7 @@ tbl_ent media_types[] = { /* * 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" }, @@ -124,7 +124,7 @@ tbl_ent bus_types[] = { * char * pointer to a string with the vendor name * */ -char * +const char * get_vendor(int vendor) { int i; @@ -148,7 +148,7 @@ get_vendor(int vendor) * char * pointer to a string with the adapter type * */ -char * +const char * get_adapter(int dev) { int i; @@ -172,7 +172,7 @@ get_adapter(int dev) * char * pointer to a string with the name of the medium * */ -char * +const char * get_media_type(int media) { int i; @@ -196,7 +196,7 @@ get_media_type(int media) * char * pointer to a string with the bus type * */ -char * +const char * get_bus_type(int bus) { int i; @@ -222,7 +222,7 @@ get_bus_type(int bus) * char * pointer to a string identifying the adapter * */ -char * +const char * get_adapter_name(char *intf) { int buf_len; @@ -242,7 +242,7 @@ get_adapter_name(char *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; @@ -269,7 +269,7 @@ get_adapter_name(char *intf) * the address of a string representing the MAC address * */ -char * +const char * format_mac_addr(Mac_addr *addr) { static char str[256]; @@ -368,7 +368,7 @@ parse_ip_prefix(char *cp, struct in_addr *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); /* diff --git a/sbin/atm/fore_dnld/fore_dnld.c b/sbin/atm/fore_dnld/fore_dnld.c index 1b0e1629fc..d7d13c0241 100644 --- a/sbin/atm/fore_dnld/fore_dnld.c +++ b/sbin/atm/fore_dnld/fore_dnld.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.6.2.2 2000/12/11 01:03:24 obrien Exp $ - * @(#) $DragonFly: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.7 2005/11/06 12:06:03 swildner Exp $ + * @(#) $DragonFly: src/sbin/atm/fore_dnld/fore_dnld.c,v 1.8 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -93,19 +93,18 @@ int verbose = 0; int reset = 0; char line[132]; -int lineptr = 0; +unsigned int lineptr = 0; Mon960 *Uart; -int sendbinfile(char *, u_char *); -void +static void delay(int cnt) { usleep(cnt); } -unsigned long +static unsigned long CP_READ ( unsigned long val ) { if ( endian ) @@ -114,7 +113,7 @@ CP_READ ( unsigned long val ) return ( val ); } -unsigned long +static unsigned long CP_WRITE ( unsigned long val ) { if ( endian ) @@ -132,8 +131,8 @@ CP_WRITE ( unsigned long val ) * Returns: * none */ -void -error ( char *msg ) +static void +error ( const char *msg ) { printf ( "%s\n", msg ); exit (1); @@ -142,14 +141,11 @@ error ( char *msg ) /* * Get a byte for the uart and if printing, display it. * - * Arguments: - * prn Are we displaying characters - * * Returns: * c Character from uart */ -char -getbyte ( int prn ) +static char +getbyte ( void ) { int c; @@ -189,15 +185,15 @@ getbyte ( int prn ) * Returns: * none Line in global string 'line[]' */ -void +static void getline ( int prn ) { char c = '\0'; - int i = 0; + unsigned int i = 0; while ( c != '>' && c != '\n' && c != '\r' ) { - c = getbyte(0); + c = getbyte(); if ( ++i >= sizeof(line) ) { if ( prn ) @@ -223,7 +219,7 @@ getline ( int prn ) * Returns: * none */ -void +static void xmit_byte ( unsigned char c, int dn ) { int val; @@ -231,14 +227,14 @@ xmit_byte ( unsigned char c, int dn ) while ( CP_READ(Uart->mon_xmitmon) != UART_READY ) { if ( CP_READ(Uart->mon_xmithost) & UART_VALID ) - getbyte ( 0 ); + getbyte (); if ( !dn ) delay ( 10000 ); } val = ( c | UART_VALID ); Uart->mon_xmitmon = CP_WRITE( val ); if ( !dn ) delay ( 10000 ); if ( CP_READ(Uart->mon_xmithost) & UART_VALID ) - getbyte ( 0 ); + getbyte(); } @@ -246,20 +242,20 @@ xmit_byte ( unsigned char c, int dn ) * Transmit a line to the i960. Eol must be included as part of text to transmit. * * Arguments: - * line Character string to transmit + * str Character string to transmit * len len of string. This allows us to include NULL's * in the string/block to be transmitted. * * Returns: * none */ -void -xmit_to_i960 ( char *line, int len, int dn ) +static void +xmit_to_i960 ( const char *str, int len, int dn ) { int i; for ( i = 0; i < len; i++ ) - xmit_byte ( line[i], dn ); + xmit_byte ( str[i], dn ); } /* @@ -271,7 +267,7 @@ xmit_to_i960 ( char *line, int len, int dn ) * Returns: * none */ -void +static void autobaud(void) { if ( strncmp ( line, "Mon960", 6 ) == 0 ) @@ -288,7 +284,7 @@ autobaud(void) * none * */ -void +static void finish ( int ret ) { sgtty.c_lflag |= ( ICANON | ECHO ); @@ -308,7 +304,7 @@ finish ( int ret ) * fname striped filename * */ -char * +static char * basename ( char *path ) { char *fname; @@ -400,7 +396,7 @@ unsigned short crctab[1< NAKMAX ) error ( "Remote system not responding" ); @@ -561,7 +557,7 @@ xmitfile ( char *filename ) /* * Get response from i960 */ - sendresp = getbyte(0); + sendresp = getbyte(); /* * If i960 didn't like the sector @@ -574,7 +570,7 @@ xmitfile ( char *filename ) * Are we supposed to cancel the transfer? */ if ( ( sendresp & 0x7f ) == CAN ) - if ( getbyte(0) == CAN ) + if ( getbyte() == CAN ) error ( "Send canceled at user's request" ); } @@ -615,7 +611,7 @@ xmitfile ( char *filename ) /* * Wait until i960 acknowledges us */ - while ( ( c = getbyte(0) ) != ACK && ( ++attempts < RETRYMAX ) ) + while ( ( c = getbyte() ) != ACK && ( ++attempts < RETRYMAX ) ) xmit_byte ( EOT, 1 ); if ( attempts >= RETRYMAX ) @@ -652,7 +648,7 @@ xmitfile ( char *filename ) } -int +static int loadmicrocode ( u_char *ucode, int size, u_char *ram ) { struct { @@ -708,7 +704,7 @@ loadmicrocode ( u_char *ucode, int size, u_char *ram ) * Load file */ if ( endian ) { - int i; + unsigned int i; lp = (u_long *) ucode; /* Swap buffer */ @@ -748,7 +744,7 @@ loadmicrocode ( u_char *ucode, int size, u_char *ram ) return ( 0 ); } -int +static int sendbinfile ( char *fname, u_char *ram ) { struct { @@ -831,7 +827,7 @@ sendbinfile ( char *fname, u_char *ram ) */ while ( ( n = read ( fd, (char *)buffer, sizeof(buffer))) > 0 ) { - int i; + unsigned int i; /* Swap buffer */ for ( i = 0; i < sizeof(buffer) / sizeof(long); i++ ) @@ -908,7 +904,7 @@ main( int argc, char **argv ) struct atminfreq req; struct air_cfg_rsp *air; /* Config info response structure */ int buf_len; /* Size of ioctl buffer */ - char *devname = "\0"; /* Device to download */ + const char *dev = "\0"; /* Device to download */ char *dirname = NULL; /* Directory path to objd files */ char *objfile = NULL; /* Command line object filename */ u_char *ucode = NULL; /* Pointer to microcode */ @@ -918,7 +914,6 @@ main( int argc, char **argv ) char base[64]; /* sba200/sba200e/pca200e basename */ int ext = 0; /* 0 == bin 1 == objd */ struct stat sbuf; /* Used to find if .bin or .objd */ - extern char *optarg; progname = (char *)basename(argv[0]); comm_mode = strcmp ( progname, "fore_comm" ) == 0; @@ -935,7 +930,7 @@ main( int argc, char **argv ) endian++; break; case 'i': - devname = (char *)strdup ( optarg ); + dev = (char *)strdup ( optarg ); break; case 'f': objfile = (char *)strdup ( optarg ); @@ -981,7 +976,7 @@ main( int argc, char **argv ) /* * Copy interface name into ioctl request */ - strcpy ( req.air_cfg_intf, devname ); + strcpy ( req.air_cfg_intf, dev ); /* * Issue ioctl @@ -1003,7 +998,7 @@ main( int argc, char **argv ) /* * Loop through all attached adapters */ - for (; req.air_buf_len >= sizeof(struct air_cfg_rsp); + for (; (size_t)req.air_buf_len >= sizeof(struct air_cfg_rsp); buf += sizeof(struct air_cfg_rsp), req.air_buf_len -= sizeof(struct air_cfg_rsp)) { @@ -1140,24 +1135,24 @@ main( int argc, char **argv ) } if ( ns ) { - int c; + int c1; int nr; - nr = read ( fileno(stdin), &c, 1 ); - c &= 0xff; + nr = read ( fileno(stdin), &c1, 1 ); + c1 &= 0xff; if ( !esc_seen ) { - if ( c == 27 ) + if ( c1 == 27 ) esc_seen++; else - xmit_byte ( c, 0 ); + xmit_byte ( c1, 0 ); } else { - if ( c == 27 ) + if ( c1 == 27 ) finish( -1 ); else { xmit_byte ( 27, 0 ); esc_seen = 0; } - xmit_byte ( c, 0 ); + xmit_byte ( c1, 0 ); } } @@ -1165,7 +1160,7 @@ main( int argc, char **argv ) * Check for data from the i960 */ if ( CP_READ(Uart->mon_xmithost) & UART_VALID ) { - c = getbyte(0); + c = getbyte(); putchar ( c ); } if ( strcmp ( line, "Mon960" ) == 0 ) diff --git a/sbin/atm/ilmid/ilmid.c b/sbin/atm/ilmid/ilmid.c index 85628177ae..efe0712bd4 100644 --- a/sbin/atm/ilmid/ilmid.c +++ b/sbin/atm/ilmid/ilmid.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sbin/atm/ilmid/ilmid.c,v 1.6.2.2 2001/03/04 07:15:30 kris Exp $ - * @(#) $DragonFly: src/sbin/atm/ilmid/ilmid.c,v 1.7 2005/11/06 12:06:03 swildner Exp $ + * @(#) $DragonFly: src/sbin/atm/ilmid/ilmid.c,v 1.8 2006/10/16 00:15:35 pavalos Exp $ */ /* @@ -87,7 +87,7 @@ #define ASN_IPADDR 0x40 #define ASN_TIMESTAMP 0x43 -static char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL", "ASN_OBJID" }; +static const char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL", "ASN_OBJID" }; /* * Define SNMP PDU types @@ -98,7 +98,7 @@ static char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL", #define PDU_TYPE_SET 0xA3 #define PDU_TYPE_TRAP 0xA4 -static char *PDU_Types[] = { "GET REQUEST", "GETNEXT REQUEST", "GET RESPONSE", "SET REQUEST", +static const char *PDU_Types[] = { "GET REQUEST", "GETNEXT REQUEST", "GET RESPONSE", "SET REQUEST", "TRAP" }; /* @@ -286,7 +286,7 @@ u_char Resp_Buf[1024]; /* * TRAP generic trap types */ -char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp", +const char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp", "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" }; @@ -330,11 +330,7 @@ char hostname[80]; #define LOG_FILE "/var/log/ilmid" FILE *Log; /* File descriptor for log messages */ -void set_reqid ( u_char *, int ); -void Increment_DL ( int ); -void Decrement_DL ( int ); - -static char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", +static const char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; /* @@ -350,14 +346,14 @@ static char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", * none * */ -void +static void write_timestamp(void) { - time_t clock; + time_t clk; struct tm *tm; - clock = time ( (time_t)NULL ); - tm = localtime ( &clock ); + clk = time ( (time_t)NULL ); + tm = localtime ( &clk ); if ( Log && Debug_Level > 1 ) if ( Log != stderr ) @@ -380,7 +376,7 @@ write_timestamp(void) * none * */ -void +static void hexdump ( u_char *bp, int len ) { int i, j; @@ -442,7 +438,7 @@ hexdump ( u_char *bp, int len ) * - decoded length * */ -int +static int asn_get_pdu_len ( u_char **bufp, int *plen ) { u_char *bp = *bufp; @@ -481,10 +477,8 @@ asn_get_pdu_len ( u_char **bufp, int *plen ) * - value encoding represented * */ -int -asn_get_encoded ( bufp, len ) - u_char **bufp; - int *len; +static int +asn_get_encoded ( u_char **bufp, int *len ) { u_char *bp = *bufp; int val = 0; @@ -522,10 +516,8 @@ asn_get_encoded ( bufp, len ) * - value of encoded integer * */ -int -asn_get_int ( bufp, plen ) - u_char **bufp; - int *plen; +static int +asn_get_int ( u_char **bufp, int *plen ) { int i; int len; @@ -556,17 +548,15 @@ asn_get_int ( bufp, plen ) * - updated buffer pointer * */ -void -asn_set_int ( bufp, val ) - u_char **bufp; - int val; +static void +asn_set_int ( u_char **bufp, int val ) { union { int i; u_char c[4]; } u; int len = sizeof(int); - int i = 0; + unsigned int i = 0; u_char *bp = *bufp; /* Check for special case where val == 0 */ @@ -605,9 +595,8 @@ asn_set_int ( bufp, val ) * none * */ -void -print_objid ( objid ) - Objid *objid; +static void +print_objid ( Objid *objid ) { int i; @@ -642,11 +631,8 @@ print_objid ( objid ) * plen - (possibly) adjusted PDU length * */ -void -asn_get_objid ( bufp, objid, plen ) - u_char **bufp; - Objid *objid; - int *plen; +static void +asn_get_objid ( u_char **bufp, Objid *objid, int *plen ) { int len; u_char *bp = *bufp; @@ -672,10 +658,8 @@ asn_get_objid ( bufp, objid, plen ) * Put OBJID - assumes elements <= 16383 for two byte coding * */ -int -asn_put_objid ( bufp, objid ) - u_char **bufp; - Objid *objid; +static int +asn_put_objid ( u_char **bufp, Objid *objid ) { int len = 0; u_char *bp = *bufp; @@ -720,11 +704,8 @@ asn_put_objid ( bufp, objid ) * plen - (possibly) adjusted PDU length * */ -void -asn_get_octet ( bufp, octet, plen ) - u_char **bufp; - char *octet; - int *plen; +static void +asn_get_octet ( u_char **bufp, char *octet, int *plen ) { u_char *bp = *bufp; int i = 0; @@ -734,7 +715,7 @@ asn_get_octet ( bufp, octet, plen ) * &i is really a dummy value here as we don't keep track * of the ongoing buffer length */ - len = asn_get_encoded ( &bp, &i, plen ); + len = asn_get_encoded ( &bp, &i ); for ( i = 0; i < len; i++ ) { *octet++ = *bp++; @@ -758,9 +739,8 @@ asn_get_octet ( bufp, octet, plen ) * none * */ -void -print_header ( Hdr ) - Snmp_Header *Hdr; +static void +print_header ( Snmp_Header *Hdr ) { Variable *var; @@ -817,15 +797,13 @@ print_header ( Hdr ) * none * */ -void -parse_oids ( h, bp ) - Snmp_Header *h; - caddr_t *bp; +static void +parse_oids ( Snmp_Header *h, u_char **bp ) { int len = h->varlen; int sublen; Variable *var; - caddr_t bufp = *bp; + u_char *bufp = *bp; while ( len > 0 ) { if ( *bufp++ == ASN_SEQUENCE ) { @@ -903,9 +881,8 @@ parse_oids ( h, bp ) * - generated SNMP header * */ -Snmp_Header * -asn_get_header ( bufp ) - u_char **bufp; +static Snmp_Header * +asn_get_header ( u_char **bufp ) { Snmp_Header *h; u_char *bp = *bufp; @@ -1015,9 +992,8 @@ asn_get_header ( bufp ) * 1 - Objid's don't match * */ -int -oid_cmp ( oid1, oid2 ) - Objid *oid1, *oid2; +static int +oid_cmp ( Objid *oid1, Objid *oid2 ) { int i; int len; @@ -1057,10 +1033,8 @@ oid_cmp ( oid1, oid2 ) * 1 - Objid's don't match * */ -int -oid_ncmp ( oid1, oid2, len ) - Objid *oid1, *oid2; - int len; +static int +oid_ncmp ( Objid *oid1, Objid *oid2, int len ) { int i; @@ -1088,11 +1062,10 @@ oid_ncmp ( oid1, oid2, len ) * -1 - no matching Variable found * */ -int -find_var ( var ) - Variable *var; +static int +find_var ( Variable *var ) { - int i; + unsigned int i; for ( i = 0; i < NUM_OIDS; i++ ) if ( oid_cmp ( &var->oid, &Objids[i] ) == 0 ) { @@ -1113,7 +1086,7 @@ find_var ( var ) * number of ticks * */ -int +static int get_ticks(void) { struct timeval timenow; @@ -1157,10 +1130,8 @@ get_ticks(void) * none * */ -void -build_pdu ( hdr, type ) - Snmp_Header *hdr; - int type; +static void +build_pdu ( Snmp_Header *hdr, int type ) { u_char *bp = Resp_Buf; u_char *vpp; @@ -1374,9 +1345,8 @@ build_pdu ( hdr, type ) return; } -void -free_pdu ( hdr ) -Snmp_Header *hdr; +static void +free_pdu ( Snmp_Header *hdr ) { Variable *var; @@ -1389,6 +1359,7 @@ Snmp_Header *hdr; UM_FREE ( hdr ); /* Free fixed portion */ } +#if 0 /* * Set Request ID in PDU * @@ -1400,10 +1371,8 @@ Snmp_Header *hdr; * none - request id may/may not be set * */ -void -set_reqid ( resp, reqid ) - u_char *resp; - int reqid; +static void +set_reqid ( u_char *resp, int reqid ) { u_char *bp = (u_char *)&resp[18]; union { @@ -1420,6 +1389,7 @@ set_reqid ( resp, reqid ) return; } +#endif /* * Send a generic response packet @@ -1433,11 +1403,8 @@ set_reqid ( resp, reqid ) * none - response sent * */ -void -send_resp ( intf, Hdr, resp ) - int intf; - Snmp_Header *Hdr; - u_char *resp; +static void +send_resp ( int intf, Snmp_Header *Hdr, u_char *resp ) { int n; @@ -1460,7 +1427,7 @@ send_resp ( intf, Hdr, resp ) * Build a COLD_START TRAP PDU * */ -Snmp_Header * +static Snmp_Header * build_cold_start(void) { Snmp_Header *hdr; @@ -1491,7 +1458,7 @@ build_cold_start(void) * Build a Generic PDU Header * */ -Snmp_Header * +static Snmp_Header * build_generic_header(void) { Snmp_Header *hdr; @@ -1519,8 +1486,8 @@ build_generic_header(void) * none Information from HARP available * */ -void -init_ilmi() +static void +init_ilmi(void) { struct air_cfg_rsp *cfg_info = NULL; struct air_int_rsp *intf_info = NULL; @@ -1590,8 +1557,8 @@ init_ilmi() * none * */ -void -ilmi_open () +static void +ilmi_open (void) { struct sockaddr_atm satm; struct t_atm_aal5 aal5; @@ -1799,10 +1766,8 @@ ilmi_open () * none * */ -void -get_local_ip ( s, aval ) - int s; - long *aval; +static void +get_local_ip ( int s, long *aval ) { char intf_name[IFNAMSIZ]; int namelen = IFNAMSIZ; @@ -1853,11 +1818,8 @@ get_local_ip ( s, aval ) * none * */ -void -set_prefix ( oid, hdr, intf ) - Objid *oid; - Snmp_Header *hdr; - int intf; +static void +set_prefix ( Objid *oid, __unused Snmp_Header *hdr, int intf ) { struct atmsetreq asr; Atm_addr *aa; @@ -1920,10 +1882,8 @@ set_prefix ( oid, hdr, intf ) } -void -set_address ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +set_address ( __unused Snmp_Header *hdr, int intf ) { Variable *var; int i, j; @@ -1967,9 +1927,8 @@ set_address ( hdr, intf ) * fname striped filename * */ -char * -basename ( path ) - char *path; +static char * +basename ( char *path ) { char *fname; @@ -1993,9 +1952,8 @@ basename ( path ) * none - Debug_Level incremented * */ -void -Increment_DL ( sig ) - int sig; +static void +Increment_DL ( __unused int sig ) { Debug_Level++; if ( Debug_Level && Log == (FILE *)NULL ) { @@ -2027,9 +1985,8 @@ Increment_DL ( sig ) * none - Debug_Level decremented * */ -void -Decrement_DL ( sig ) - int sig; +static void +Decrement_DL ( __unused int sig ) { Debug_Level--; if ( Debug_Level <= 0 ) { @@ -2050,10 +2007,8 @@ Decrement_DL ( sig ) * Loop through GET variable list looking for matches * */ -void -process_get ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +process_get ( Snmp_Header *hdr, int intf ) { Variable *var; int idx; @@ -2108,7 +2063,7 @@ process_get ( hdr, intf ) case IPNM_OBJID: var->type = ASN_IPADDR; get_local_ip ( ilmi_fd[intf], - &var->var.ival ); + &var->var.aval ); break; case ADDRESS_OBJID: break; @@ -2138,8 +2093,8 @@ process_get ( hdr, intf ) * * */ -void -ilmi_do_state () +static void +ilmi_do_state (void) { struct timeval tvp; fd_set rfd; @@ -2154,7 +2109,7 @@ ilmi_do_state () for ( ; ; ) { int count; int n; - caddr_t bpp; + u_char *bpp; Snmp_Header *Hdr; /* @@ -2284,8 +2239,8 @@ ilmi_do_state () * Should be because the remote side is attempting * to verify that our table is empty */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[ADDRESS_OBJID], + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[ADDRESS_OBJID], Objids[ADDRESS_OBJID].oid[0] ) == 0 ) { if ( addressEntry[intf].oid[0] ) { /* XXX - FIXME */ @@ -2340,8 +2295,8 @@ ilmi_do_state () break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[SETPFX_OBJID], + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[SETPFX_OBJID], Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ @@ -2381,8 +2336,8 @@ ilmi_do_state () break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[SETPFX_OBJID], + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[SETPFX_OBJID], Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ @@ -2412,9 +2367,7 @@ ilmi_do_state () } int -main ( argc, argv ) - int argc; - char *argv[]; +main ( int argc, char *argv[] ) { int c; int i; @@ -2465,8 +2418,7 @@ main ( argc, argv ) if ( foregnd == 0 ) { if ( daemon ( 0, 0 ) ) err ( 1, "Can't fork" ); - } else - ; /* setbuf ( stdout, NULL ); */ + } signal ( SIGUSR1, Increment_DL ); signal ( SIGUSR2, Decrement_DL ); @@ -2530,4 +2482,3 @@ main ( argc, argv ) exit(0); } - -- 2.41.0