[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] ios: Remove usage of xalloc from ios-dev-file.c
From: |
Tim Rühsen |
Subject: |
[PATCH 1/3] ios: Remove usage of xalloc from ios-dev-file.c |
Date: |
Thu, 7 May 2020 14:02:33 +0200 |
2020-05-07 Tim Rühsen <address@hidden>
* libpoke/ios-dev-file.c (ios_dev_file_open): Replace
xmalloc and xstrdup by malloc and strdup.
Remove include xalloc.h.
---
ChangeLog | 6 ++++++
libpoke/ios-dev-file.c | 33 ++++++++++++++++++++++++---------
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
index 14b6ba0a..fb42ed4f 100644
--- a/libpoke/ios-dev-file.c
+++ b/libpoke/ios-dev-file.c
@@ -25,7 +25,6 @@
#include <fcntl.h>
#include <stdio.h>
-#include <xalloc.h>
#include <string.h>
#include <sys/stat.h>
@@ -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
- [PATCH 1/3] ios: Remove usage of xalloc from ios-dev-file.c,
Tim Rühsen <=