summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-09-12 07:53:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-09-12 07:53:05 +0200
commit9b1102c02bfd39352e0d2995c733edb7be3b0601 (patch)
tree3f089c640bab75c020b69f5dcf44d744a0a7f2e4 /lib
parentf48a1596f4e911d4516b986e4778f18321b39b48 (diff)
parenta10dbfc4175867c0d15f02b7f244837c5d41478e (diff)
downloadbarebox-9b1102c02bfd39352e0d2995c733edb7be3b0601.tar.gz
barebox-9b1102c02bfd39352e0d2995c733edb7be3b0601.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'lib')
-rw-r--r--lib/gui/png_lode.c13
-rw-r--r--lib/libfile.c9
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/gui/png_lode.c b/lib/gui/png_lode.c
index 477704d976..e30db0f853 100644
--- a/lib/gui/png_lode.c
+++ b/lib/gui/png_lode.c
@@ -46,15 +46,16 @@ struct image *png_open(char *inbuf, int insize)
LodePNGState state;
int ret;
unsigned error;
- struct image *img = calloc(1, sizeof(struct image));
- unsigned char *png;
-
- if (!img)
- return ERR_PTR(-ENOMEM);
+ struct image *img;
+ unsigned char *png = NULL;
ret = png_uncompress_init();
if (ret)
- goto err;
+ return ERR_PTR(ret);
+
+ img = calloc(1, sizeof(struct image));
+ if (!img)
+ return ERR_PTR(-ENOMEM);
lodepng_state_init(&state);
diff --git a/lib/libfile.c b/lib/libfile.c
index b42753c2b5..3f3ec21fdb 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -38,7 +38,7 @@ int pwrite_full(int fd, const void *buf, size_t size, loff_t offset)
now = pwrite(fd, buf, size, offset);
if (now == 0) {
errno = ENOSPC;
- return -1;
+ return -errno;
}
if (now < 0)
return now;
@@ -66,7 +66,7 @@ int write_full(int fd, const void *buf, size_t size)
now = write(fd, buf, size);
if (now == 0) {
errno = ENOSPC;
- return -1;
+ return -errno;
}
if (now < 0)
return now;
@@ -194,6 +194,7 @@ again:
buf = calloc(read_size + 1, 1);
if (!buf) {
ret = -ENOMEM;
+ errno = ENOMEM;
goto err_out;
}
@@ -241,9 +242,9 @@ EXPORT_SYMBOL(read_file_2);
*
* This function reads a file to an allocated buffer.
* Some TFTP servers do not transfer the size of a file. In this case
- * a the file is first read to a temporary file.
+ * the file is first read to a temporary file.
*
- * Return: The buffer conataining the file or NULL on failure
+ * Return: The buffer containing the file or NULL on failure
*/
void *read_file(const char *filename, size_t *size)
{