[PATCH] Eliminate GCC warnings

Jim Paris jim at jtan.com
Sun Dec 16 22:26:12 CET 2007


> Hello list,
> 
> I just attempt to eliminate GCC warnings resulting from "-Wall
> - -std=gnu99" cflags.
> 
> Most changes are trivial including fixes against typo and removing
> unused codes.  Also, this changes prototypes for parser-oriented
> functions with const modifier.   Please refer to the attachment for
> details.

Hi Jim,

some comments inline


> Index: include/gsmd/gsmd.h
> ===================================================================
> --- include/gsmd/gsmd.h	(revision 3656)
> +++ include/gsmd/gsmd.h	(working copy)
> @@ -4,6 +4,7 @@
>  #ifdef __GSMD__
>  
>  #include <sys/types.h>
> +#include <sys/time.h>
>  
>  #include <common/linux_list.h>
>  
> @@ -118,6 +119,9 @@ void __gsmd_log(int level, const char *f
>  
>  extern int gsmd_simplecmd(struct gsmd *gsmd, char *cmdtxt);
>  
> +extern int gsmd_initsettings(struct gsmd *gsmd);
> +extern int gmsd_alive_start(struct gsmd *gsmd);
> +
>  /***********************************************************************
>   * timer handling
>   ***********************************************************************/
> @@ -130,7 +134,7 @@ struct gsmd_timer {
>  };
>  
>  int gsmd_timer_init(void);
> -void gmsd_timer_check_n_run(void);
> +void gsmd_timer_check_n_run(void);
>  
>  struct gsmd_timer *gsmd_timer_alloc(void);
>  int gsmd_timer_register(struct gsmd_timer *timer);
> Index: include/gsmd/sms.h
> ===================================================================
> --- include/gsmd/sms.h	(revision 3656)
> +++ include/gsmd/sms.h	(working copy)
> @@ -18,7 +18,8 @@ int cbs_pdu_to_msg(struct gsmd_cbm *dst,
>  
>  int usock_rcv_sms(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len);
>  int usock_rcv_cb(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len);
> -
> +int sms_pdu_decode_dcs(struct gsmd_sms_datacodingscheme *dcs,
> +		const u_int8_t *data);
>  #endif /* __GSMD__ */
>  
>  #endif
> Index: include/gsmd/vendorplugin.h
> ===================================================================
> --- include/gsmd/vendorplugin.h	(revision 3656)
> +++ include/gsmd/vendorplugin.h	(working copy)
> @@ -11,14 +11,15 @@ struct gsmd_unsolicit;
>  
>  struct gsmd_vendor_plugin {
>  	struct llist_head list;
> -	unsigned char *name;
> -	unsigned char *ext_chars;
> +	char *name;
> +	char *ext_chars;
>  	unsigned int num_unsolicit;
>  	const struct gsmd_unsolicit *unsolicit;
>  	int (*detect)(struct gsmd *g);
>  	int (*initsettings)(struct gsmd *g);
>  };
>  
> +extern int gsmd_vendor_plugin_load(char *name);
>  extern int gsmd_vendor_plugin_register(struct gsmd_vendor_plugin *pl);
>  extern void gsmd_vendor_plugin_unregister(struct gsmd_vendor_plugin *pl);
>  extern int gsmd_vendor_plugin_find(struct gsmd *g);
> Index: include/gsmd/unsolicited.h
> ===================================================================
> --- include/gsmd/unsolicited.h	(revision 3656)
> +++ include/gsmd/unsolicited.h	(working copy)
> @@ -7,14 +7,18 @@
>  
>  struct gsmd_unsolicit {
>  	const char *prefix;
> -	int (*parse)(char *unsol, int len, const char *param, struct gsmd *gsmd);
> +	int (*parse)(const char *unsol,
> +			int len, const char *param, struct gsmd *gsmd);
>  };
>  
> -extern int unsolicited_parse(struct gsmd *g, char *buf, int len, const char *param);
> +extern void unsolicited_init(struct gsmd *g);
> +extern int unsolicited_parse(struct gsmd *g,
> +		const char *buf, int len, const char *param);
>  extern int generate_event_from_cme(struct gsmd *g, unsigned int cme_error);
>  extern void unsolicited_generic_init(struct gsmd *g);
>  extern int unsolicited_register_array(const struct gsmd_unsolicit *arr,
>  		int len);
> +extern int generate_event_from_cms(struct gsmd *g, unsigned int cms_error);
>  extern const int pintype_from_cme[];
>  
>  #endif /* __GSMD__ */
> Index: include/gsmd/machineplugin.h
> ===================================================================
> --- include/gsmd/machineplugin.h	(revision 3656)
> +++ include/gsmd/machineplugin.h	(working copy)
> @@ -10,13 +10,15 @@ struct gsmd;
>  
>  struct gsmd_machine_plugin {
>  	struct llist_head list;
> -	unsigned char *name;
> +	char *name;
>  	int (*power)(struct gsmd *g, int power);
>  	int (*ex_submit)(struct gsmd *g);
>  	int (*detect)(struct gsmd *g);
>  	int (*init)(struct gsmd *g, int fd);
>  };
>  
> +extern int gsmd_machine_plugin_init(struct gsmd *g,
> +		char *machine_name, char *vendor_name);
>  extern int gsmd_machine_plugin_register(struct gsmd_machine_plugin *pl);
>  extern void gsmd_machine_plugin_unregister(struct gsmd_machine_plugin *pl);
>  extern int gsmd_machine_plugin_find(struct gsmd *g);
> Index: include/gsmd/usock.h
> ===================================================================
> --- include/gsmd/usock.h	(revision 3656)
> +++ include/gsmd/usock.h	(working copy)
> @@ -673,6 +673,9 @@ extern int usock_evt_send(struct gsmd *g
>  extern int gsmd_ucmd_submit(struct gsmd_user *gu, u_int8_t msg_type,
>  		u_int8_t msg_subtype, u_int16_t id, int len, const void *data);
>  
> +extern int gsmd_opname_init(struct gsmd *g);
> +extern int gsmd_opname_add(struct gsmd *g, const char *numeric_bcd_string,
> +		const char *alnum_long);
>  #endif /* __GSMD__ */
>  
>  #endif
> Index: src/gsmd/machine_generic.c
> ===================================================================
> --- src/gsmd/machine_generic.c	(revision 3656)
> +++ src/gsmd/machine_generic.c	(working copy)
> @@ -41,8 +41,6 @@ static int generic_detect(struct gsmd *g
>  
>  static int generic_init(struct gsmd *g, int fd)
>  {
> -	int rc;
> -
>  	/*
>  	 * We assume that the GSM chipset can take
>  	 * input immediately, so we don't have to
> Index: src/gsmd/machine.c
> ===================================================================
> --- src/gsmd/machine.c	(revision 3656)
> +++ src/gsmd/machine.c	(working copy)
> @@ -117,7 +117,7 @@ int gsmd_machine_plugin_init(struct gsmd
>  	buf[sizeof(buf)-1] = '\0';
>  
>  	line = strtok(buf, "\n");
> -	while (line = strtok(NULL, "\n")) {
> +	while ((line = strtok(NULL, "\n"))) {
>  		if (strncmp(line, "Hardware\t: ", 11) == 0) {
>  			hw = line+11;
>  			break;
> @@ -138,7 +138,7 @@ int gsmd_machine_plugin_init(struct gsmd
>  
>  				if (vendor_name)
>  					DEBUGP("wanring: auto-detected vendor '%s', "
> -						"but user override to '%s'\m",
> +						"but user override to '%s'\n",
>  						machines[i].vendor, vendor_name);
>  				else
>  					vendor_name = machines[i].vendor;
> Index: src/gsmd/sms_cb.c
> ===================================================================
> --- src/gsmd/sms_cb.c	(revision 3656)
> +++ src/gsmd/sms_cb.c	(working copy)
> @@ -38,6 +38,7 @@
>  #include <gsmd/usock.h>
>  #include <gsmd/unsolicited.h>
>  #include <gsmd/sms.h>
> +#include <gsmd/talloc.h>
>  
>  static const char *ts0705_memtype_name[] = {
>  	[GSM0705_MEMTYPE_NONE]		= "NONE",
> @@ -402,7 +403,8 @@ int usock_rcv_cb(struct gsmd_user *gu, s
>  }
>  
>  /* Unsolicited messages related to SMS / CB */
> -static int cmti_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cmti_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	char memstr[3];
>  	struct gsmd_evt_auxdata *aux;
> @@ -424,7 +426,8 @@ static int cmti_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_SMS);
>  }
>  
> -static int cmt_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cmt_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	/* TODO: TEXT mode */
>  	u_int8_t pdu[SMS_MAX_PDU_SIZE];
> @@ -474,7 +477,8 @@ static int cmt_parse(char *buf, int len,
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_SMS);
>  }
>  
> -static int cbmi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cbmi_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	char memstr[3];
>  	struct gsmd_evt_auxdata *aux;
> @@ -496,7 +500,8 @@ static int cbmi_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CBM);
>  }
>  
> -static int cbm_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cbm_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	/* TODO: TEXT mode */
>  	u_int8_t pdu[CBM_MAX_PDU_SIZE];
> @@ -541,7 +546,8 @@ static int cbm_parse(char *buf, int len,
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CBM);
>  }
>  
> -static int cdsi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cdsi_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	char memstr[3];
>  	struct gsmd_evt_auxdata *aux;
> @@ -563,7 +569,8 @@ static int cdsi_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_DS);
>  }
>  
> -static int cds_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cds_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	/* TODO: TEXT mode */
>  	u_int8_t pdu[SMS_MAX_PDU_SIZE];
> Index: src/gsmd/vendor_bcm.c
> ===================================================================
> --- src/gsmd/vendor_bcm.c	(revision 3656)
> +++ src/gsmd/vendor_bcm.c	(working copy)
> @@ -35,7 +35,7 @@
>  #include <gsmd/vendorplugin.h>
>  #include <gsmd/unsolicited.h>
>  
> -static int mrdy_parse(char *buf, int len, const char *param,
> +static int mrdy_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *g)
>  {
>  	int status = atoi(param);
> @@ -70,12 +70,9 @@ static int mrdy_parse(char *buf, int len
>  	return 0;
>  }
>  
> -static int mtsmenu_parse(char *buf, int len, const char *param,
> +static int mtsmenu_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *g)
>  {
> -	char *tok, *param_tmp;
> -	struct mtsmenu *mtsmenu;
> -
>  	DEBUGP("mtsmenu_parse param=`%s'\n", param);
>  	return 0;
>  }
> @@ -95,8 +92,7 @@ static int bcm_detect(struct gsmd *g)
>  
>  static int bcm_initsettings(struct gsmd *g)
>  {
> -	int rc;
> -	struct gsmd_atcmd *cmd;
> +	int rc = 0;
>  
>  	/* bcm sometimes sends LFCR instead of CRLF (eg *MTSMENU message) */
>  	g->llp.flags |= LGSM_ATCMD_F_LFCR;
> Index: src/gsmd/ext_response.c
> ===================================================================
> --- src/gsmd/ext_response.c	(revision 3656)
> +++ src/gsmd/ext_response.c	(working copy)
> @@ -67,7 +67,6 @@ struct gsm_extrsp *extrsp_parse(const vo
>  {
>  	const char *cur = input;
>  	struct gsm_extrsp *er;
> -	int cur_tok = 0;
>  	enum parser_state state = IDLE;
>  	char buf[512];
>  	char *cur_buf = buf;
> @@ -205,7 +204,8 @@ void extrsp_dump(const struct gsm_extrsp
>  				DEBUGP("%d-%d, ", tok->u.range.item[j].min,
>  					tok->u.range.item[j].max);
>  			}
> -			
> +			break;
> +		default:
>  			break;
>  		}
>  	}
> Index: src/gsmd/vendor_qc.c
> ===================================================================
> --- src/gsmd/vendor_qc.c	(revision 3656)
> +++ src/gsmd/vendor_qc.c	(working copy)
> @@ -36,10 +36,9 @@
>  #include <gsmd/vendorplugin.h>
>  #include <gsmd/unsolicited.h>
>  
> -static int htccsq_parse(char *buf, int len, const char *param,
> +static int htccsq_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *gsmd)
>  {
> -	char *tok;
>  	struct gsmd_evt_auxdata *aux;
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL,
>  					     sizeof(*aux));
> @@ -63,13 +62,14 @@ static int htccsq_parse(char *buf, int l
>  	usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL);
>  
>  	return 0;
> -
> +#if 0
>  out_free_io:
>  	free(ucmd);
>  	return -EIO;
> +#endif
>  }
>  
> -static int wcdma_parse(char *buf, int len, const char *param,
> +static int wcdma_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *gsmd)
>  {
>  	return 0;
> @@ -96,8 +96,7 @@ static int qc_detect(struct gsmd *g)
>  
>  static int qc_initsettings(struct gsmd *g)
>  {
> -	int rc;
> -	struct gsmd_atcmd *cmd;
> +	int rc = 0;
>  
>  	/* enable @HTCCSQ: signal quality reports */
>  	rc |= gsmd_simplecmd(g, "AT at HTCCSQ=1");
> Index: src/gsmd/timer.c
> ===================================================================
> --- src/gsmd/timer.c	(revision 3656)
> +++ src/gsmd/timer.c	(working copy)
> @@ -37,11 +37,13 @@
>  static LLIST_HEAD(gsmd_timers);
>  static void *__tmr_ctx;
>  
> +#if 0
>  static void tv_normalize(struct timeval *out)
>  {
>  	out->tv_sec += (out->tv_usec / 1000000);
>  	out->tv_usec = (out->tv_usec % 1000000);
>  }
> +#endif
>  
>  /* subtract two struct timevals */
>  static int tv_sub(struct timeval *res, const struct timeval *from,
> @@ -58,6 +60,7 @@ static int tv_sub(struct timeval *res, c
>  	return 0;
>  }
>  
> +#if 0
>  static int tv_add(struct timeval *res, const struct timeval *a1,
>  		  const struct timeval *a2)
>  {
> @@ -68,6 +71,7 @@ static int tv_add(struct timeval *res, c
>  
>  	tv_normalize(res);
>  }
> +#endif
>  
>  static int tv_later(const struct timeval *expires, const struct timeval *now)
>  {
> Index: src/gsmd/unsolicited.c
> ===================================================================
> --- src/gsmd/unsolicited.c	(revision 3656)
> +++ src/gsmd/unsolicited.c	(working copy)
> @@ -35,6 +35,7 @@
>  #include <gsmd/ts0707.h>
>  #include <gsmd/unsolicited.h>
>  #include <gsmd/talloc.h>
> +#include <gsmd/sms.h>
>  
>  struct gsmd_ucmd *usock_build_event(u_int8_t type, u_int8_t subtype, u_int16_t len)
>  {
> @@ -147,7 +148,7 @@ static void state_ringing_update(struct 
>  				&state_ringing_timeout, gsmd);
>  }
>  
> -static int ring_parse(char *buf, int len, const char *param,
> +static int ring_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>          struct gsmd_ucmd *ucmd;
> @@ -167,7 +168,7 @@ static int ring_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_IN_CALL);
>  }
>  
> -static int cring_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cring_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
>  {
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_CALL,
>  					     sizeof(struct gsmd_evt_auxdata));
> @@ -201,7 +202,7 @@ static int cring_parse(char *buf, int le
>  }
>  
>  /* Chapter 7.2, network registration */
> -static int creg_parse(char *buf, int len, const char *param,
> +static int creg_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	const char *comma = strchr(param, ',');
> @@ -250,7 +251,7 @@ static int creg_parse(char *buf, int len
>  }
>  
>  /* Chapter 7.11, call waiting */
> -static int ccwa_parse(char *buf, int len, const char *param,
> +static int ccwa_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	const char *token;
> @@ -266,7 +267,7 @@ static int ccwa_parse(char *buf, int len
>  	memset(gaddr, 0, sizeof(*gaddr));
>  
>  	/* parse address (phone number) */
> -	token = strtok(buf, ",");
> +	token = strtok((char *) buf, ",");

Calling strtok on a const pointer is bad, and hiding it with a cast
doesn't help anything.  As noted in the strtok manpage: "Avoid using
these functions.  If you do use them, note that: These functions
modify their first argument.  These functions cannot be used on
constant strings".  I think something like strpbrk would work 
here:
       
	token = strpbrk(buf, ",");
	if (!token) 
		return -EINVAL;
	strncpy(gaddr->number, token+1, GSMD_ADDR_MAXLEN);

or similar.

>  	if (!token)
>  		return -EINVAL;
>  	strncpy(gaddr->number, token, GSMD_ADDR_MAXLEN);
> @@ -285,7 +286,7 @@ static int ccwa_parse(char *buf, int len
>  }
>  
>  /* Chapter 7.14, unstructured supplementary service data */
> -static int cusd_parse(char *buf, int len, const char *param,
> +static int cusd_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	/* FIXME: parse */
> @@ -293,7 +294,7 @@ static int cusd_parse(char *buf, int len
>  }
>  
>  /* Chapter 7.15, advise of charge */
> -static int cccm_parse(char *buf, int len, const char *param,
> +static int cccm_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	/* FIXME: parse */
> @@ -301,7 +302,7 @@ static int cccm_parse(char *buf, int len
>  }
>  
>  /* Chapter 10.1.13, GPRS event reporting */
> -static int cgev_parse(char *buf, int len, const char *param,
> +static int cgev_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	/* FIXME: parse */
> @@ -309,7 +310,7 @@ static int cgev_parse(char *buf, int len
>  }
>  
>  /* Chapter 10.1.14, GPRS network registration status */
> -static int cgreg_parse(char *buf, int len, const char *param,
> +static int cgreg_parse(const char *buf, int len, const char *param,
>  		       struct gsmd *gsmd)
>  {
>  	/* FIXME: parse */
> @@ -317,7 +318,7 @@ static int cgreg_parse(char *buf, int le
>  }
>  
>  /* Chapter 7.6, calling line identification presentation */
> -static int clip_parse(char *buf, int len, const char *param,
> +static int clip_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_IN_CLIP,
> @@ -345,7 +346,7 @@ static int clip_parse(char *buf, int len
>  }
>  
>  /* Chapter 7.9, calling line identification presentation */
> -static int colp_parse(char *buf, int len, const char *param,
> +static int colp_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_OUT_COLP,
> @@ -371,7 +372,7 @@ static int colp_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_OUT_COLP);
>  }
>  
> -static int ctzv_parse(char *buf, int len, const char *param,
> +static int ctzv_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_TIMEZONE,
> @@ -395,7 +396,7 @@ static int ctzv_parse(char *buf, int len
>  	return usock_evt_send(gsmd, ucmd, GSMD_EVT_TIMEZONE);
>  }
>  
> -static int copn_parse(char *buf, int len, const char *param,
> +static int copn_parse(const char *buf, int len, const char *param,
>  		      struct gsmd *gsmd)
>  {
>  	struct gsm_extrsp *er = extrsp_parse(gsmd_tallocs, param);
> @@ -444,11 +445,10 @@ static const struct gsmd_unsolicit gsm07
>  static struct gsmd_unsolicit unsolicit[256] = {{ 0, 0 }};
>  
>  /* called by midlevel parser if a response seems unsolicited */
> -int unsolicited_parse(struct gsmd *g, char *buf, int len, const char *param)
> +int unsolicited_parse(struct gsmd *g, const char *buf, int len, const char *param)
>  {
>  	struct gsmd_unsolicit *i;
>  	int rc;
> -	struct gsmd_vendor_plugin *vpl = g->vendorpl;
>  
>  	/* call unsolicited code parser */
>  	for (i = unsolicit; i->prefix; i ++) {
> Index: src/gsmd/usock.c
> ===================================================================
> --- src/gsmd/usock.c	(revision 3656)
> +++ src/gsmd/usock.c	(working copy)
> @@ -43,7 +43,7 @@
>  #include <gsmd/ts0707.h>
>  #include <gsmd/sms.h>
>  
> -static void *__ucmd_ctx, *__gu_ctx, *__pb_ctx;
> +static void *__ucmd_ctx, *__gu_ctx;
>  
>  struct gsmd_ucmd *ucmd_alloc(int extra_size)
>  {
> @@ -112,6 +112,7 @@ static int usock_rcv_event(struct gsmd_u
>  		return -EINVAL;
>  
>  	gu->subscriptions = *evtmask;
> +	return 0;
>  }
>  
>  static int voicecall_get_stat_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) 
> @@ -464,9 +465,9 @@ static int usock_rcv_modem(struct gsmd_u
>  static int network_vmail_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
>  {
>  	struct gsmd_user *gu = ctx;
> -	struct gsmd_voicemail *vmail;
> +	struct gsmd_voicemail *vmail = (struct gsmd_voicemail *)
> +		malloc(sizeof(struct gsmd_voicemail));

Some fixes like this one look quite important, not just to silence
compiler warnings.  Maybe splitting them out in a separate patch would
be helpful?

>  	struct gsmd_ucmd *ucmd;
> -	char *comma;
>  
>  	DEBUGP("entering(cmd=%p, gu=%p)\n", cmd, gu);
>  
> @@ -506,7 +507,7 @@ static int network_vmail_cb(struct gsmd_
>  	}
>  
>  	usock_cmd_enqueue(ucmd, gu);
> -
> +	free(vmail);
>  	return 0;
>  
>  out_free_einval:
> @@ -736,7 +737,6 @@ static int usock_rcv_network(struct gsmd
>  			     int len)
>  {
>  	struct gsmd_atcmd *cmd;
> -	struct gsmd_voicemail *vmail = (struct gsmd_voicemail *) gph->data;
>  	gsmd_oper_numeric *oper = (gsmd_oper_numeric *) gph->data;
>  	char buffer[15 + sizeof(gsmd_oper_numeric)];
>  	int cmdlen;
> @@ -745,7 +745,7 @@ static int usock_rcv_network(struct gsmd
>  	case GSMD_NETWORK_REGISTER:
>  		if ((*oper)[0])
>  			cmdlen = sprintf(buffer, "AT+COPS=1,2,\"%.*s\"",
> -					sizeof(gsmd_oper_numeric), oper);
> +					sizeof(gsmd_oper_numeric), *oper);

ditto

>  		else
>  			cmdlen = sprintf(buffer, "AT+COPS=0");
>  		cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL);
> @@ -784,7 +784,7 @@ static int usock_rcv_network(struct gsmd
>  		break;
>  	case GSMD_NETWORK_PREF_ADD:
>  		cmdlen = sprintf(buffer, "AT+CPOL=,2,\"%.*s\"",
> -				sizeof(gsmd_oper_numeric), oper);
> +				sizeof(gsmd_oper_numeric), *oper);

ditto

>  		cmd = atcmd_fill(buffer, cmdlen + 1, &null_cmd_cb, gu, 0, NULL);
>  		break;
>  	case GSMD_NETWORK_PREF_SPACE:
> @@ -1021,7 +1021,7 @@ static int phonebook_list_storage_cb(str
>  		char* delim = "(,";
>  		ptr = strpbrk(resp, delim);
>  		while (ptr) {
> -			strncpy(gps.mem[gps.num].type, ptr + 2, 2);
> +			strncpy((char *) gps.mem[gps.num].type, ptr + 2, 2);
>  			gps.mem[gps.num].type[2] = '\0';
>  			ptr = strpbrk(ptr + 2, delim);
>  			gps.num++;
> @@ -1041,9 +1041,8 @@ static int usock_rcv_phonebook(struct gs
>  	struct gsmd_phonebook_readrg *gpr;
>  	struct gsmd_phonebook *gp;
>  	struct gsmd_phonebook_find *gpf;
> -	struct gsmd_phonebooks *cur, *cur2;
> -	int *index, *num;
> -	int atcmd_len, i, ret;
> +	int *index;
> +	int atcmd_len;
>  	char *storage;
>  	char buf[1024];
>  
> Index: src/gsmd/atcmd.c
> ===================================================================
> --- src/gsmd/atcmd.c	(revision 3656)
> +++ src/gsmd/atcmd.c	(working copy)
> @@ -49,12 +49,14 @@ enum final_result_codes {
>  	NUM_FINAL_RESULTS,
>  };
>  
> +#if 0
>  static const char *final_results[] = {
>  	"OK",
>  	"ERROR",
>  	"+CME ERROR:",
>  	"+CMS ERROR:",
>  };
> +#endif
>  
>  /* we basically implement a parse that can deal with
>   * - receiving and queueing commands from higher level of libgmsd
> @@ -188,8 +190,8 @@ static int llparse_init(struct llparser 
>  	return 0;
>  }
>  
> +#if 0
>  /* mid-level parser */
> -
>  static int parse_final_result(const char *res)
>  {
>  	int i;
> @@ -200,6 +202,7 @@ static int parse_final_result(const char
>  	
>  	return -1;
>  }
> +#endif
>  
>  void atcmd_wake_pending_queue (struct gsmd *g) 
>  {
> @@ -224,10 +227,10 @@ static int atcmd_done(struct gsmd *g, st
>                  /* send final result code if there is no information
>                  * response in mlbuf */
>                  if (g->mlbuf_len) {
> -                        cmd->resp = g->mlbuf;
> +                        cmd->resp = (char *) g->mlbuf;
>                          g->mlbuf[g->mlbuf_len] = 0;
>                  } else {
> -                        cmd->resp = buf;
> +                        cmd->resp = (char *) buf;

Again, casting away the "const" here from buf defeats the purpose.
Maybe a copy could be made?

>                  }
>                  rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
>                  DEBUGP("Clearing mlbuf\n");
> @@ -367,7 +370,7 @@ static int ml_parse(const char *buf, int
>  					gsmd_log(GSMD_NOTICE, "command without cb!!!\n");
>  				} else {
>  					DEBUGP("Calling cmd->cb()\n");
> -					cmd->resp = g->mlbuf;
> +					cmd->resp = (char *) g->mlbuf;
>  					rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
>  					DEBUGP("Clearing mlbuf\n");
>  					memset(g->mlbuf, 0, MLPARSE_BUF_SIZE);
> @@ -429,8 +432,9 @@ static int ml_parse(const char *buf, int
>  	g->mlbuf_len += len;
>  
>  	if (g->mlunsolicited) {
> -		rc = unsolicited_parse(g, g->mlbuf, g->mlbuf_len,
> -				strchr(g->mlbuf, ':') + 1);
> +		rc = unsolicited_parse(g, (const char *) g->mlbuf,
> +				(int) g->mlbuf_len,
> +				strchr((const char *)g->mlbuf, ':') + 1);
>  		if (rc == -EAGAIN) {
>  			/* The parser wants one more line of
>  			 * input.  Wait for the next line, concatenate
> @@ -464,6 +468,7 @@ static int atcmd_prompt(void *data)
>  	struct gsmd *g = data;
>  
>          atcmd_wake_pending_queue(g);
> +	return 0;
>  }
>  
>  /* callback to be called if [virtual] UART has some data for us */
> @@ -642,8 +647,6 @@ static int remove_timer(struct gsmd_atcm
>  /* submit an atcmd in the global queue of pending atcmds */
>  int atcmd_submit(struct gsmd *g, struct gsmd_atcmd *cmd)
>  {
> -        int empty;
> -
>  	if (g->machinepl->ex_submit) {
>  		DEBUGP("extra-submiting command\n");
>  		g->machinepl->ex_submit(g);
> Index: src/gsmd/vendor_tihtc.c
> ===================================================================
> --- src/gsmd/vendor_tihtc.c	(revision 3656)
> +++ src/gsmd/vendor_tihtc.c	(working copy)
> @@ -52,10 +52,9 @@ int gsmd_simplecmd(struct gsmd *gsmd, ch
>  	return atcmd_submit(gsmd, cmd);
>  }
>  
> -static int htccsq_parse(char *buf, int len, const char *param,
> +static int htccsq_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *gsmd)
>  {
> -	char *tok;
>  	struct gsmd_evt_auxdata *aux;
>  	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL,
>  					     sizeof(*aux));
> @@ -79,17 +78,19 @@ static int htccsq_parse(char *buf, int l
>  	usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL);
>  
>  	return 0;
> -
> +#if 0
>  out_free_io:
>  	free(ucmd);
>  	return -EIO;
> +#endif
>  }
>  
> -static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cpri_parse(const char *buf, int len, const char *param,
> +		struct gsmd *gsmd)
>  {
>  	char *tok1, *tok2;
>  
> -	tok1 = strtok(buf, ",");
> +	tok1 = strtok((char *) buf, ",");

strtok const

>  	if (!tok1)
>  		return -EIO;
>  
> @@ -126,7 +127,7 @@ static int cpri_parse(char *buf, int len
>  }
>  
>  /* Call Progress Information */
> -static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cpi_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
>  {
>  	char *tok;
>  	struct gsmd_evt_auxdata *aux;
> @@ -143,7 +144,7 @@ static int cpi_parse(char *buf, int len,
>  	/* Format: cId, msgType, ibt, tch, dir,[mode],[number],[type],[alpha],[cause],line */
>  
>  	/* call ID */
> -	tok = strtok(buf, ",");
> +	tok = strtok((char *) buf, ",");

strtok const

>  	if (!tok)
>  		goto out_free_io;
>  
> @@ -248,7 +249,7 @@ static int tihtc_detect(struct gsmd *g)
>  
>  static int tihtc_initsettings(struct gsmd *g)
>  {
> -	int rc;
> +	int rc = 0;
>  	struct gsmd_atcmd *cmd;
>  
>  	/* use %CGREG */
> Index: src/gsmd/vendor_ti.c
> ===================================================================
> --- src/gsmd/vendor_ti.c	(revision 3656)
> +++ src/gsmd/vendor_ti.c	(working copy)
> @@ -38,7 +38,7 @@
>  #include <gsmd/unsolicited.h>
>  
>  
> -static int csq_parse(char *buf, int len, const char *param,
> +static int csq_parse(const char *buf, int len, const char *param,
>  		     struct gsmd *gsmd)
>  {
>  	struct gsmd_evt_auxdata *aux;
> @@ -63,11 +63,11 @@ out_free_io:
>  	return -EIO;
>  }
>  
> -static int cpri_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cpri_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
>  {
>  	char *tok1, *tok2;
>  
> -	tok1 = strtok(buf, ",");
> +	tok1 = strtok((char *) buf, ",");

strtok const

>  	if (!tok1)
>  		return -EIO;
>  	
> @@ -103,7 +103,7 @@ static int cpri_parse(char *buf, int len
>  	return 0;
>  }
>  
> -static int ctzv_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int ctzv_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
>  {
>  	/* FIXME: decide what to do with it.  send as event to clients? or keep
>  	 * locally? Offer option to sync system RTC? */
> @@ -111,7 +111,7 @@ static int ctzv_parse(char *buf, int len
>  }
>  
>  /* Call Progress Information */
> -static int cpi_parse(char *buf, int len, const char *param, struct gsmd *gsmd)
> +static int cpi_parse(const char *buf, int len, const char *param, struct gsmd *gsmd)
>  {
>  	char *tok;
>  	struct gsmd_evt_auxdata *aux;
> @@ -128,7 +128,7 @@ static int cpi_parse(char *buf, int len,
>  	/* Format: cId, msgType, ibt, tch, dir,[mode],[number],[type],[alpha],[cause],line */
>  
>  	/* call ID */
> -	tok = strtok(buf, ",");
> +	tok = strtok((char *) buf, ",");

strtok const

>  	if (!tok)
>  		goto out_free_io;
>  
> Index: src/gsmd/gsmd.c
> ===================================================================
> --- src/gsmd/gsmd.c	(revision 3656)
> +++ src/gsmd/gsmd.c	(working copy)
> @@ -44,6 +44,8 @@
>  #include <gsmd/usock.h>
>  #include <gsmd/vendorplugin.h>
>  #include <gsmd/talloc.h>
> +#include <gsmd/sms.h>
> +#include <gsmd/unsolicited.h>
>  
>  #define GSMD_ALIVECMD		"AT"
>  #define GSMD_ALIVE_INTERVAL	5*60
> @@ -157,7 +159,7 @@ int gsmd_simplecmd(struct gsmd *gsmd, ch
>  
>  static int gsmd_initsettings2(struct gsmd *gsmd)
>  {
> -	int rc;
> +	int rc = 0;
>  	
>  	/* echo on, verbose */
>  	rc |= gsmd_simplecmd(gsmd, "ATE0V1");
> @@ -213,6 +215,7 @@ static int firstcmd_atcb(struct gsmd_atc
>  	return gsmd_initsettings2(gsmd);
>  }
>  
> +#if 0
>  static void firstcmd_tmr_cb(struct gsmd_timer *tmr, void *data)
>  {
>  	if (firstcmd_response == 0) {
> @@ -221,11 +224,11 @@ static void firstcmd_tmr_cb(struct gsmd_
>  	}
>  	gsmd_timer_free(tmr);
>  }
> +#endif
>  
>  int gsmd_initsettings(struct gsmd *gsmd)
>  {
>  	struct gsmd_atcmd *cmd;
> -	struct timeval tv;
>  
>  	cmd = atcmd_fill("ATZ", strlen("ATZ")+1, &firstcmd_atcb, gsmd, 0, NULL);
>  	if (!cmd)
> @@ -364,7 +367,6 @@ int main(int argc, char **argv)
>  	int bps = 115200;
>  	int hwflow = 0;
>  	char *device = NULL;
> -	char *logfile = "syslog";
>  	char *vendor_name = NULL;
>  	char *machine_name = NULL;
>  	int wait = -1;
> @@ -473,7 +475,7 @@ int main(int argc, char **argv)
>  		exit(1);
>  	}
>  
> -        write(fd,'\r',1);
> +        write(fd, "\r", 1);

another important fix?

>  	atcmd_drain(fd);
>  
>  	if (usock_init(&g) < 0) {
> Index: src/util/event.c
> ===================================================================
> --- src/util/event.c	(revision 3656)
> +++ src/util/event.c	(working copy)
> @@ -115,7 +115,7 @@ static int incbm_handler(struct lgsm_han
>  				msg->page, msg->pages);
>  
>  		if (msg->coding_scheme == ALPHABET_DEFAULT) {
> -			cbm_unpacking_7bit_character(msg->data, payload);
> +			cbm_unpacking_7bit_character((char *)msg->data, payload);
>  			printf("\"%s\"\n", payload);
>  		} else if (msg->coding_scheme == ALPHABET_8BIT)
>  			printf("8-bit encoded data\n");
> @@ -176,6 +176,8 @@ static int netreg_handler(struct lgsm_ha
>  	case GSMD_NETREG_REG_ROAMING:
>  		printf("registered (roaming) ");
>  		break;
> +	default:
> +		break;
>  	}
>  
>  	if (aux->u.netreg.lac)
> Index: src/util/pin.c
> ===================================================================
> --- src/util/pin.c	(revision 3656)
> +++ src/util/pin.c	(working copy)
> @@ -52,7 +52,7 @@ static int pin_handler(struct lgsm_handl
>  	} else {
>  		do {
>  			printf("Please enter %s: ", lgsm_pin_name(type));
> -			rc = fscanf(stdin, "%8s", &pinbuf);
> +			rc = fscanf(stdin, "%8s", pinbuf);

ditto

>  		} while (rc < 1);
>  
>  		switch (type) {
> @@ -60,7 +60,7 @@ static int pin_handler(struct lgsm_handl
>  		case GSMD_PIN_SIM_PUK2:
>  			do {
>  				printf("Please enter new PIN: ");
> -				rc = fscanf(stdin, "%8s", &pinbuf2);
> +				rc = fscanf(stdin, "%8s", pinbuf2);

ditto

>  				newpin = pinbuf2;
>  			} while (rc < 1);
>  			break;
> Index: src/util/shell.c
> ===================================================================
> --- src/util/shell.c	(revision 3656)
> +++ src/util/shell.c	(working copy)
> @@ -31,6 +31,7 @@
>  #include <libgsmd/misc.h>
>  #include <libgsmd/phonebook.h>
>  #include <libgsmd/sms.h>
> +#include <libgsmd/pin.h>
>  #include <gsmd/usock.h>
>  #include <gsmd/ts0705.h>
>  
> @@ -49,6 +50,7 @@ static int pt_msghandler(struct lgsm_han
>  {
>  	char *payload = (char *)gmh + sizeof(*gmh);
>  	printf("RSTR=`%s'\n", payload);
> +	return 0;
>  }
>  
>  /* this is the handler for receiving phonebook responses */
> @@ -135,7 +137,8 @@ static int pb_msghandler(struct lgsm_han
>  		break;
>  	default:
>  		return -EINVAL;
> -	}	
> +	}
> +	return 0;
>  }
>  
>  /* this is the handler for receiving sms responses */
> @@ -273,6 +276,7 @@ static int sms_msghandler(struct lgsm_ha
>  		pending_responses --;
>  		return -EINVAL;
>  	}
> +	return 0;
>  }
>  
>  /* this is the handler for responses to network/operator commands */
> @@ -344,6 +348,7 @@ static int net_msghandler(struct lgsm_ha
>  	default:
>  		return -EINVAL;
>  	}
> +	return 0;
>  }
>  
>  static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
> @@ -441,7 +446,7 @@ static const struct msghandler_s {
>  	{ 0, 0 }
>  };
>  
> -static int shell_help(void)
> +static void shell_help(void)
>  {
>  	printf( "\tA\tAnswer incoming call\n"
>  		"\tD\tDial outgoing number\n"
> @@ -487,8 +492,6 @@ int shell_main(struct lgsm_handle *lgsmh
>  {
>  	int rc;
>  	char buf[STDIN_BUF_SIZE+1];
> -	char rbuf[STDIN_BUF_SIZE+1];
> -	int rlen = sizeof(rbuf);
>  	fd_set readset;
>  	char *ptr, *fcomma, *lcomma;
>  	int gsm_fd = lgsm_fd(lgsmh);
> @@ -780,4 +783,5 @@ int shell_main(struct lgsm_handle *lgsmh
>  		}
>  		fflush(stdout);
>  	}
> +	return 0;
>  }
> Index: src/util/atcmd.c
> ===================================================================
> --- src/util/atcmd.c	(revision 3656)
> +++ src/util/atcmd.c	(working copy)
> @@ -35,6 +35,7 @@ static int pt_msghandler(struct lgsm_han
>  {
>  	char *payload = (char *)gmh + sizeof(*gmh);
>  	printf("RSTR=`%s'\n", payload);
> +	return 0;
>  }
>  
>  int atcmd_main(struct lgsm_handle *lgsmh)
> @@ -42,7 +43,7 @@ int atcmd_main(struct lgsm_handle *lgsmh
>  	int rc;
>  	char buf[STDIN_BUF_SIZE+1];
>  	char rbuf[STDIN_BUF_SIZE+1];
> -	int rlen = sizeof(rbuf);
> +	unsigned int rlen = sizeof(rbuf);
>  	fd_set readset;
>  
>  	lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
> @@ -99,4 +100,5 @@ int atcmd_main(struct lgsm_handle *lgsmh
>  			fflush(stdout);
>  		}
>  	}
> +	return 0;
>  }


-jim



More information about the gsmd-devel mailing list