[zaptel-commits] tzafrir: trunk r1423 - /trunk/xpp/

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Wed Sep 6 14:25:15 MST 2006


Author: tzafrir
Date: Wed Sep  6 16:25:15 2006
New Revision: 1423

URL: http://svn.digium.com/view/zaptel?rev=1423&view=rev
Log:
Fix problems reported by sparse

Modified:
    trunk/xpp/card_fxo.c
    trunk/xpp/card_fxs.c
    trunk/xpp/xbus-core.c
    trunk/xpp/xbus-core.h
    trunk/xpp/xdefs.h
    trunk/xpp/xpd.h
    trunk/xpp/xpp_zap.c
    trunk/xpp/xproto.h

Modified: trunk/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxo.c?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/card_fxo.c (original)
+++ trunk/xpp/card_fxo.c Wed Sep  6 16:25:15 2006
@@ -489,7 +489,7 @@
 			DBG("-- Setting echo registers: \n");
 			/* first off: check if this span is fxs. If not: -EINVALID */
 			if (copy_from_user(&echoregs.wctdm_struct, 
-				(struct wctdm_echo_coefs*)arg, sizeof(echoregs.wctdm_struct)))
+				(struct wctdm_echo_coefs __user *)arg, sizeof(echoregs.wctdm_struct)))
 				return -EFAULT;
 
 			/* Set the ACIM register */
@@ -990,8 +990,7 @@
 static int proc_xpd_slic_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
 {
 	xpd_t		*xpd = data;
-	const int	LINE_LEN = 500;
-	char		buf[LINE_LEN];
+	char		buf[MAX_PROC_WRITE];
 	char		*p;
 	int		i;
 	int		ret;
@@ -999,7 +998,7 @@
 	if(!xpd)
 		return -ENODEV;
 	for(i = 0; i < count; /* noop */) {
-		for(p = buf; p < buf + LINE_LEN; p++) {	/* read a line */
+		for(p = buf; p < buf + MAX_PROC_WRITE; p++) {	/* read a line */
 			if(i >= count)
 				break;
 			if(get_user(*p, buffer + i))
@@ -1008,7 +1007,7 @@
 			if(*p == '\n' || *p == '\r')	/* whatever */
 				break;
 		}
-		if(p >= buf + LINE_LEN)
+		if(p >= buf + MAX_PROC_WRITE)
 			return -E2BIG;
 		*p = '\0';
 		ret = process_slic_cmdline(xpd, buf);

Modified: trunk/xpp/card_fxs.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxs.c?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/card_fxs.c (original)
+++ trunk/xpp/card_fxs.c Wed Sep  6 16:25:15 2006
@@ -989,8 +989,7 @@
 static int proc_xpd_slic_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
 {
 	xpd_t		*xpd = data;
-	const int	LINE_LEN = 500;
-	char		buf[LINE_LEN];
+	char		buf[MAX_PROC_WRITE];
 	char		*p;
 	int		i;
 	int		ret;
@@ -998,7 +997,7 @@
 	if(!xpd)
 		return -ENODEV;
 	for(i = 0; i < count; /* noop */) {
-		for(p = buf; p < buf + LINE_LEN; p++) {	/* read a line */
+		for(p = buf; p < buf + MAX_PROC_WRITE; p++) {	/* read a line */
 			if(i >= count)
 				break;
 			if(get_user(*p, buffer + i))
@@ -1007,7 +1006,7 @@
 			if(*p == '\n' || *p == '\r')	/* whatever */
 				break;
 		}
-		if(p >= buf + LINE_LEN)
+		if(p >= buf + MAX_PROC_WRITE)
 			return -E2BIG;
 		*p = '\0';
 		ret = process_slic_cmdline(xpd, buf);

Modified: trunk/xpp/xbus-core.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xbus-core.c?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xbus-core.c (original)
+++ trunk/xpp/xbus-core.c Wed Sep  6 16:25:15 2006
@@ -103,7 +103,7 @@
  * 	Receive packets:
  * 	  - Allocated/deallocated by xbus_xmiter
  */
-xpacket_t	*xbus_packet_new(xbus_t *xbus, int flags)
+xpacket_t	*xbus_packet_new(xbus_t *xbus, gfp_t flags)
 {
 	xpacket_t	*pack;
 
@@ -787,15 +787,14 @@
 #ifdef	PROTOCOL_DEBUG
 static int proc_xbus_command_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
 {
-	const int		NUM_SIZE = 100;
-	char			buf[NUM_SIZE];
+	char			buf[MAX_PROC_WRITE];
 	xbus_t			*xbus = data;
 	xpacket_t		*pack;
 	char			*p;
 	byte			*pack_contents;
 	byte			*q;
 
-	if(count >= NUM_SIZE) {
+	if(count >= MAX_PROC_WRITE) {
 		ERR("%s: line too long\n", __FUNCTION__);
 		return -EFBIG;
 	}
@@ -967,7 +966,7 @@
 		return -ENOMEM;
 	}
 #ifdef CONFIG_PROC_FS
-	proc_xbuses = create_proc_read_entry(PROC_XBUSES, 0444, xpp_proc_toplevel, read_proc_xbuses, 0);
+	proc_xbuses = create_proc_read_entry(PROC_XBUSES, 0444, xpp_proc_toplevel, read_proc_xbuses, NULL);
 	if (!proc_xbuses) {
 		ERR("Failed to create proc file %s\n", PROC_XBUSES);
 		xbus_core_cleanup();

Modified: trunk/xpp/xbus-core.h
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xbus-core.h?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xbus-core.h (original)
+++ trunk/xpp/xbus-core.h Wed Sep  6 16:25:15 2006
@@ -30,7 +30,7 @@
 void xbus_core_shutdown(void);		/* Terminator */
 
 /* Packet handling */
-xpacket_t *xbus_packet_new(xbus_t *xbus, int flags);
+xpacket_t *xbus_packet_new(xbus_t *xbus, gfp_t flags);
 void xbus_packet_free(xbus_t *xbus, xpacket_t *p);
 
 /* packet queues */

Modified: trunk/xpp/xdefs.h
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xdefs.h?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xdefs.h (original)
+++ trunk/xpp/xdefs.h Wed Sep  6 16:25:15 2006
@@ -55,6 +55,7 @@
 #define	IS_SET(x,i)	(((x) & BIT(i)) != 0)
 #define	BITMASK(i)	(BIT(i) - 1)
 
+#define	MAX_PROC_WRITE	100	/* Largest buffer we allow writing our /proc files */
 #define	CHANNELS_PERXPD	30	/* Depends on xpp_line_t and protocol fields */
 
 #define	MAX_SPANNAME	20	/* From zaptel.h */

Modified: trunk/xpp/xpd.h
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpd.h?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xpd.h (original)
+++ trunk/xpp/xpd.h Wed Sep  6 16:25:15 2006
@@ -37,6 +37,9 @@
 #include <zaptel.h>
 
 #ifdef __KERNEL__
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+typedef	unsigned gfp_t;		/* Added in 2.6.14 */
+#endif
 #define	DEF_PARM(type,name,init,desc)	\
 	type name = init;	\
 	module_param(name, type, 0600);		\
@@ -83,7 +86,7 @@
 
 struct xbus_ops {
 	int (*packet_send)(xbus_t *xbus, xpacket_t *packet);
-	xpacket_t *(*packet_new)(xbus_t *xbus, int flags);
+	xpacket_t *(*packet_new)(xbus_t *xbus, gfp_t flags);
 	void (*packet_free)(xbus_t *xbus, xpacket_t *p);
 };
 

Modified: trunk/xpp/xpp_zap.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpp_zap.c?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xpp_zap.c (original)
+++ trunk/xpp/xpp_zap.c Wed Sep  6 16:25:15 2006
@@ -716,8 +716,7 @@
 
 static int proc_sync_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
 {
-	const int	NUM_SIZE = 100;
-	char		buf[NUM_SIZE];
+	char		buf[MAX_PROC_WRITE];
 	int		xbus_num;
 	int		xpd_num;
 	xbus_t		*xbus;
@@ -726,7 +725,7 @@
 	bool		setit;
 
 	// DBG("%s: count=%ld\n", __FUNCTION__, count);
-	if(count >= NUM_SIZE)
+	if(count >= MAX_PROC_WRITE)
 		return -EINVAL;
 	if(copy_from_user(buf, buffer, count))
 		return -EFAULT;
@@ -793,13 +792,12 @@
 static int proc_xpd_ztregister_write(struct file *file, const char __user *buffer, unsigned long count, void *data)
 {
 	xpd_t		*xpd = data;
-	const int	NUM_SIZE = 100;
-	char		buf[NUM_SIZE];
+	char		buf[MAX_PROC_WRITE];
 	bool		zt_reg;
 	int		ret;
 
 	BUG_ON(!xpd);
-	if(count >= NUM_SIZE)
+	if(count >= MAX_PROC_WRITE)
 		return -EINVAL;
 	if(copy_from_user(buf, buffer, count))
 		return -EFAULT;
@@ -1103,7 +1101,7 @@
 
 	switch (cmd) {
 		case ZT_ONHOOKTRANSFER:
-			if (get_user(x, (int *)arg))
+			if (get_user(x, (int __user *)arg))
 				return -EFAULT;
 			xpd->ohttimer[pos] = x << 3;
 			xpd->idletxhookstate[pos] = FXS_LINE_CID;	/* OHT mode when idle */
@@ -1114,7 +1112,7 @@
 			DBG("xpd=%d: ZT_ONHOOKTRANSFER (%d millis) chan=%d\n", xpd->id, x, pos);
 			return -ENOTTY;
 		case ZT_TONEDETECT:
-			if (get_user(x, (int *)arg))
+			if (get_user(x, (int __user *)arg))
 				return -EFAULT;
 			DBG("xpd=%d: ZT_TONEDETECT chan=%d: TONEDETECT_ON=%d TONEDETECT_MUTE=%d\n",
 				xpd->id, pos, (x & ZT_TONEDETECT_ON), (x & ZT_TONEDETECT_MUTE));

Modified: trunk/xpp/xproto.h
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xproto.h?rev=1423&r1=1422&r2=1423&view=diff
==============================================================================
--- trunk/xpp/xproto.h (original)
+++ trunk/xpp/xproto.h Wed Sep  6 16:25:15 2006
@@ -101,7 +101,7 @@
 	((p)->datalen + sizeof(xpd_addr_t) + 1)
 
 #define	XENTRY(card,op)					\
-	[ XPROTO_NAME(card,op) ] {			\
+	[ XPROTO_NAME(card,op) ] = {			\
 		.handler = XPROTO_HANDLER(card,op),	\
 		.datalen = RPACKET_DATALEN(card,op),	\
 		.name = #op,				\



More information about the zaptel-commits mailing list