poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] ios: Remove usage of xalloc from ios-dev-file.c


From: Jose E. Marchesi
Subject: Re: [PATCH 1/4] ios: Remove usage of xalloc from ios-dev-file.c
Date: Thu, 14 May 2020 21:15:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Tim.

This looks OK.
Thanks!
    
    @@ -66,7 +65,7 @@ ios_dev_file_handler_normalize (const char *handler)
     static void *
     ios_dev_file_open (const char *handler, uint64_t flags, int *error)
     {
    -  struct ios_dev_file *fio;
    +  struct ios_dev_file *fio = NULL;
       FILE *f;
       const char *mode;
       uint8_t flags_mode = flags & IOS_FLAGS_MODE;
    @@ -106,19 +105,35 @@ ios_dev_file_open (const char *handler, uint64_t 
flags, int *error)
         }
    
       if (!f)
    -    {
    -      if (error != NULL)
    -        *error = IOD_ERROR;
    +    goto err;
    
    -      return NULL;
    -    }
    +  fio = malloc (sizeof (struct ios_dev_file));
    +  if (!fio)
    +    goto err;
    +
    +  fio->filename = strdup (handler);
    +  if (!fio->filename)
    +    goto err;
    
    -  fio = xmalloc (sizeof (struct ios_dev_file));
       fio->file = f;
    -  fio->filename = xstrdup (handler);
       fio->flags = flags;
    
       return fio;
    +
    +err:
    +  if (fio)
    +    {
    +      free (fio->filename);
    +      free (fio);
    +    }
    +
    +  if (f)
    +    fclose (f);
    +
    +  if (error != NULL)
    +    *error = IOD_ERROR;
    +
    +  return NULL;
     }
    
     static int
    --
    2.26.2



reply via email to

[Prev in Thread] Current Thread [Next in Thread]