[Spread-cvs] commit: r278 - trunk/examples

jonathan at spread.org jonathan at spread.org
Mon Sep 19 17:31:52 EDT 2005


Author: jonathan
Date: 2005-09-19 17:31:52 -0400 (Mon, 19 Sep 2005)
New Revision: 278

Modified:
   trunk/examples/fl_user.c
   trunk/examples/user.c
Log:
Apply fix (with small change) from Neil Conway for unnecessary char -> int cast. 


Modified: trunk/examples/fl_user.c
===================================================================
--- trunk/examples/fl_user.c	2005-09-19 21:26:32 UTC (rev 277)
+++ trunk/examples/fl_user.c	2005-09-19 21:31:52 UTC (rev 278)
@@ -176,8 +176,8 @@
 	  break;
 	}
       printf("enter message: ");
-      ret = (int) fgets( mess, 200, stdin );
-      if( ret==0 ) Bye();
+	  if (fgets(mess, 200, stdin) == NULL)
+		  Bye();
       mess_len = strlen( mess );
 
       printf("user.c : multicasting message of size %d:\n'%s'\n", mess_len, mess);
@@ -195,8 +195,8 @@
       ret = sscanf( &command[2], "%s", group );
       if( ret != 1 ) strcpy( group, "dummy_group_name" );
       printf("enter size of each message: ");
-      ret = (int) fgets( mess, 200, stdin );
-      if( ret==0 ) Bye();
+	  if (fgets(mess, 200, stdin) == NULL)
+		  Bye();
       ret = sscanf(mess, "%d", &mess_len );
       if( ret !=1 ) mess_len = Previous_len;
       if( mess_len < 0 ) mess_len = 0;

Modified: trunk/examples/user.c
===================================================================
--- trunk/examples/user.c	2005-09-19 21:26:32 UTC (rev 277)
+++ trunk/examples/user.c	2005-09-19 21:31:52 UTC (rev 278)
@@ -215,7 +215,8 @@
 	int	i;
 
 	for( i=0; i < sizeof(command); i++ ) command[i] = 0;
-	if( fgets( command, 130, stdin ) == 0 ) Bye();
+	if( fgets( command, 130, stdin ) == NULL ) 
+            Bye();
 
 	switch( command[0] )
 	{
@@ -253,8 +254,8 @@
 				break;
 			}
 			printf("enter message: ");
-			ret = (int) fgets( mess, 200, stdin );
-			if( ret==0 ) Bye();
+			if (fgets(mess, 200, stdin) == NULL)
+				Bye();
 			mess_len = strlen( mess );
 #ifdef _REENTRANT
 #ifdef __bsdi__		/* bsdi bug - doing a close when another thread blocks on the socket causes a seg fault */
@@ -280,8 +281,8 @@
 			ret=sscanf( &command[2], "%s", group );
 			if( ret != 1 ) strcpy( group, "dummy_group_name" );
 			printf("enter size of each message: ");
-			ret = (int) fgets( mess, 200, stdin );
-			if( ret==0 ) Bye();
+			if (fgets(mess, 200, stdin) == NULL)
+				Bye();
 			ret=sscanf(mess, "%u", &mess_len );
 			if( ret !=1 ) mess_len = Previous_len;
                         if( mess_len > MAX_MESSLEN ) mess_len = MAX_MESSLEN;




More information about the Spread-cvs mailing list