[Olsr-cvs] olsrd-current/src/linux apm.c,1.14,1.14.2.1

Bernd Petrovitsch (spam-protected)
Sun Nov 26 01:32:16 CET 2006


Update of /cvsroot/olsrd/olsrd-current/src/linux
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27853/src/linux

Modified Files:
      Tag: olsrd_04
	apm.c 
Log Message:
* ANSI-C doesn't allow to compare pointers < (or >) NULL, only == NULL or != NULL.
* Fixed a leaking FILE *
* Since the "buffer" variable can never be == NULL, I assume that it was meant actually that way.


Index: apm.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/apm.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -C2 -d -r1.14 -r1.14.2.1
*** apm.c	7 Apr 2005 18:22:43 -0000	1.14
--- apm.c	26 Nov 2006 00:32:14 -0000	1.14.2.1
***************
*** 191,203 ****
      return 0;
  
! 
!   fgets(buffer, sizeof(buffer) - 1, apm_procfile);
!   if(buffer == NULL)
      {
        /* Try re-opening the file */
!       if((apm_procfile = fopen(APM_PROC, "r")) < 0)
  	return 0;
!       fgets(buffer, sizeof(buffer) - 1, apm_procfile);
!       if(buffer == NULL)
  	{
  	  /* Giving up */
--- 191,201 ----
      return 0;
  
!   if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
      {
+       fclose(apm_procfile);
        /* Try re-opening the file */
!       if((apm_procfile = fopen(APM_PROC, "r")) == NULL)
  	return 0;
!       if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
  	{
  	  /* Giving up */





More information about the Olsr-cvs mailing list