Re: Gnumach cleanup 5 - Control reaches end of non-void function

2006-11-14 Thread Samuel Thibault
Hi,

Barry deFreese, le Tue 14 Nov 2006 03:59:38 -0500, a écrit :
> I realize that this reverts a couple of the things I sent on my last
> patch but several of the lpr functions really return nothing so should
> have been void in the first place.

Not necessarily.

> Index: i386/i386/trap.c
> ===
> RCS file: /cvsroot/hurd/gnumach/i386/i386/trap.c,v
> retrieving revision 1.5.2.6
> diff -u -p -r1.5.2.6 trap.c
> --- i386/i386/trap.c  11 Nov 2006 00:54:05 -  1.5.2.6
> +++ i386/i386/trap.c  14 Nov 2006 03:43:31 -
> @@ -570,6 +570,7 @@ printf("user trap %d error %d sub %08x\n
>  
>   i386_exception(exc, code, subcode);
>   /*NOTREACHED*/
> + return -1;
>  }

NOTREACHED, hence shouldn't be needed. The right fix is to mark the
declaration of i386_exception with __attribute__((noreturn)).

>  /*
> @@ -1116,6 +1117,8 @@ check_io_fault(regs)
>   /* port not mapped */
>   return FALSE;
>   }
> + /* NOTREACHED ? */
> + return FALSE;
>  }

Shouldn't be reached yes, because emulate_io shouldn't return anything
else than what is in the switch statement , but I'd rather put a
default: case in the switch statement.

> -int comprobe(), comintr(), comstart(), commctl();
> -void comattach();
> +int comprobe(), comstart(), commctl();
> +void comattach(), comstop(), comintr();
>  static void comparam();
> -int comstop(), comgetstat(), comsetstat();
> +io_return_t comgetstat(), comsetstat();

If these were defined as such, that was probably for a good reason.  And
the good reason for comstop() for instance is that the t_stop member
of the tty structure is to return an int.  So it must return an int.
Your previous patch just showed the error, don't try to fix it the wrong
way :)

> -int
> +void
>  comintr(unit)

Same here: interrupt handlers are supposed to return an int.

> Index: kern/eventcount.c
> ===
> RCS file: /cvsroot/hurd/gnumach/kern/eventcount.c,v
> retrieving revision 1.1.1.1.4.6
> diff -u -p -r1.1.1.1.4.6 eventcount.c
> --- kern/eventcount.c 13 Nov 2006 21:30:37 -  1.1.1.1.4.6
> +++ kern/eventcount.c 14 Nov 2006 03:43:33 -
> @@ -232,6 +232,7 @@ kern_return_t evc_wait_clear(natural_t e
>   simple_unlock(&ev->lock);
>   splx(s);
>   ret = KERN_NO_SPACE; /* XX */
> + return ret;
>  }

This will probably need more digging than just assuming ret was intended
to be returned, at least just because there is XX here.

> @@ -21,7 +21,7 @@
>   *  Author: Bryan Ford, University of Utah CSL
>   */
>  
> -int putchar(int c)
> +void putchar(int c)
>  {
>   cnputc(c);
>  }

putchar is a gcc built-in, supposed to return an int, so should rather
return an int.

Don't go wild ;)

Samuel


___
Bug-hurd mailing list
Bug-hurd@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-hurd


Gnumach cleanup 5 - Control reaches end of non-void function

2006-11-13 Thread Barry deFreese
Heya gents,

Just a quick one to clean the remaining warnings in the title.

I realize that this reverts a couple of the things I sent on my last
patch but several of the lpr functions really return nothing so should
have been void in the first place.

Thanks as always,

Barry deFreese (aka bddebian)
Index: i386/i386/trap.c
===
RCS file: /cvsroot/hurd/gnumach/i386/i386/trap.c,v
retrieving revision 1.5.2.6
diff -u -p -r1.5.2.6 trap.c
--- i386/i386/trap.c	11 Nov 2006 00:54:05 -	1.5.2.6
+++ i386/i386/trap.c	14 Nov 2006 03:43:31 -
@@ -570,6 +570,7 @@ printf("user trap %d error %d sub %08x\n
 
 	i386_exception(exc, code, subcode);
 	/*NOTREACHED*/
+	return -1;
 }
 
 /*
@@ -1116,6 +1117,8 @@ check_io_fault(regs)
 		/* port not mapped */
 		return FALSE;
 	}
+	/* NOTREACHED ? */
+	return FALSE;
 }
 
 #if	MACH_PCSAMPLE > 0
Index: i386/i386at/com.c
===
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/com.c,v
retrieving revision 1.3.2.4
diff -u -p -r1.3.2.4 com.c
--- i386/i386at/com.c	13 Nov 2006 21:30:36 -	1.3.2.4
+++ i386/i386at/com.c	14 Nov 2006 03:43:31 -
@@ -45,10 +45,10 @@
 
 extern void timeout(), ttrstrt();
 
-int comprobe(), comintr(), comstart(), commctl();
-void comattach();
+int comprobe(), comstart(), commctl();
+void comattach(), comstop(), comintr();
 static void comparam();
-int comstop(), comgetstat(), comsetstat();
+io_return_t comgetstat(), comsetstat();
 
 static vm_offset_t com_std[NCOM] = { 0 };
 struct bus_device *cominfo[NCOM];
@@ -487,7 +487,7 @@ unsigned int	count;
 	return (D_SUCCESS);
 }
 
-int
+void
 comintr(unit)
 int unit;
 {
@@ -807,7 +807,7 @@ commctl(
 	return commodem[unit];
 }
 
-int
+void
 comstop(tp, flags)
 register struct tty *tp;
 int	flags;
Index: i386/i386at/kd.c
===
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/kd.c,v
retrieving revision 1.5.2.11
diff -u -p -r1.5.2.11 kd.c
--- i386/i386at/kd.c	13 Nov 2006 21:30:36 -	1.5.2.11
+++ i386/i386at/kd.c	14 Nov 2006 03:43:32 -
@@ -489,7 +489,7 @@ kdopen(dev, flag, ior)
 	struct 	tty	*tp;
 	int	kdstart();
 	spl_t	o_pri;
-	int	kdstop();
+	void	kdstop();
 
 	tp = &kd_tty;
 	o_pri = spltty();
@@ -1170,7 +1170,7 @@ struct	tty	*tp;
 }
 
 /*ARGSUSED*/
-int
+void
 kdstop(tp, flags)
 	register struct tty *tp;
 	int	flags;
Index: i386/i386at/lpr.c
===
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/lpr.c,v
retrieving revision 1.1.1.1.4.9
diff -u -p -r1.1.1.1.4.9 lpr.c
--- i386/i386at/lpr.c	13 Nov 2006 21:30:36 -	1.1.1.1.4.9
+++ i386/i386at/lpr.c	14 Nov 2006 03:43:32 -
@@ -64,10 +64,11 @@ extern void 	ttrstrt();
  * Driver information for auto-configuration stuff.
  */
 
-int 	lprprobe(), lprintr(), lprstart(), lprstop();
+int 	lprprobe(), lprintr(), lprstart(); 
+void	lprstop();
 void	lprattach(struct bus_device *);
 #ifdef	MACH_KERNEL
-int lprstop(), lprgetstat(), lprsetstat();
+int lprgetstat(), lprsetstat();
 #endif	/* MACH_KERNEL */
 
 struct bus_device *lprinfo[NLPR];	/* ??? */
@@ -369,7 +370,7 @@ struct tty *tp;
 }
 
 #ifdef	MACH_KERNEL
-int
+void
 lprstop(tp, flags)
 register struct tty *tp;
 int	flags;
@@ -378,7 +379,7 @@ int	flags;
 		tp->t_state |= TS_FLUSH;
 }
 #else	/* MACH_KERNEL */
-int lprstop(tp, flag)
+void lprstop(tp, flag)
 struct tty *tp;
 {
 	int s = spltty();
Index: kern/eventcount.c
===
RCS file: /cvsroot/hurd/gnumach/kern/eventcount.c,v
retrieving revision 1.1.1.1.4.6
diff -u -p -r1.1.1.1.4.6 eventcount.c
--- kern/eventcount.c	13 Nov 2006 21:30:37 -	1.1.1.1.4.6
+++ kern/eventcount.c	14 Nov 2006 03:43:33 -
@@ -232,6 +232,7 @@ kern_return_t evc_wait_clear(natural_t e
 	simple_unlock(&ev->lock);
 	splx(s);
 	ret = KERN_NO_SPACE; /* XX */
+	return ret;
 }
 
 /*
Index: util/putchar.c
===
RCS file: /cvsroot/hurd/gnumach/util/Attic/putchar.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 putchar.c
--- util/putchar.c	25 Feb 1997 21:28:35 -	1.1.1.1
+++ util/putchar.c	14 Nov 2006 03:43:35 -
@@ -21,7 +21,7 @@
  *  Author: Bryan Ford, University of Utah CSL
  */
 
-int putchar(int c)
+void putchar(int c)
 {
 	cnputc(c);
 }
___
Bug-hurd mailing list
Bug-hurd@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-hurd