[PATCH] sync.c: Add asserts to document and check assumptions

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Nov 27 15:43:06 UTC 2014


On 27/11/14 16:31, Joel Sherrill wrote:
> ---
>   cpukit/libcsupport/src/sync.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/libcsupport/src/sync.c b/cpukit/libcsupport/src/sync.c
> index 653a177..e449cab 100644
> --- a/cpukit/libcsupport/src/sync.c
> +++ b/cpukit/libcsupport/src/sync.c
> @@ -29,6 +29,7 @@ int fdatasync(int);        /* still not always prototyped */
>   #include <stdio.h>
>   
>   #include <rtems.h>
> +#include <rtems/score/assert.h>
>   
>   /* XXX check standards -- Linux version appears to be void */
>   void _fwalk(struct _reent *, void *);
> @@ -37,14 +38,20 @@ void _fwalk(struct _reent *, void *);
>   static void sync_wrapper(FILE *f)
>   {
>     int fn = fileno(f);
> +  int rc;
>   
>     /*
>      *  We are explicitly NOT checking the return values as it does not
>      *  matter if they succeed.  We are just making a best faith attempt
>      *  at both and trusting that we were passed a good FILE pointer.
>      */
> -  fsync(fn);
> -  fdatasync(fn);
> +  _Assert( fn != -1 );

I don't think this assert is useful, what about -2 and 99999999? Its the 
job of fsync() and fdatasync() to deal with this.

> +
> +  rc = fsync(fn);
> +  _Assert( rc == 0 );
> +
> +  rc = fdatasync(fn);
> +  _Assert( rc == 0 );
>   }
>   
>   /* iterate over all FILE *'s for this thread */

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list