crypto: digest: Return -errno if open() fails
PATCH 1/3 crypto: digest: Return -errno if open() fails
Strictly speaking, open() doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'.
--- crypto/digest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/digest.c +1 -1
@@ -289,7 +289,7 @@ int digest_file_window(struct digest *d, const char *filename, fd =open (filename,O_RDONLY );if (fd <0 ) {perror (filename); -return fd; +return -errno; } buf =memmap (fd,PROT_READ );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 crypto: digest: Return -errno if lseek() fails
Strictly speaking, lseek() doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'. In this case this change also allows us to avoid potential problems from downconverting 'loff_t' to 'int'.
--- crypto/digest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
crypto/digest.c +2 -2
@@ -226,9 +226,9 @@ static int digest_update_from_fd(struct digest *d, int fd,unsigned char *buf =xmalloc (PAGE_SIZE );int ret =0 ; - ret =lseek (fd, start,SEEK_SET ); -if (ret ==-1 ) { +if (lseek (fd, start,SEEK_SET ) != start) {perror ("lseek" ); + ret = -errno; goto out_free; }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] crypto: digest: Return -errno if lseek() fails
Quoted 15 lines · Andrey Smirnov
Strictly speaking,
lseek()doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'. In this case this change also allows us to avoid potential problems from downconverting 'loff_t' to 'int'.Signed-off-by Andrey Smirnov <[email protected]>--- crypto/digest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)crypto/digest.c +0
-0
crypto/digest.c static int digest_update_from_fd(struct digest *d, int fd, · line 233
Quoted 10 lines
crypto/digest.c +2
-2@@ -226,9 +226,9 @@ static int digest_update_from_fd(struct digest *d, int fd,unsigned char *buf =xmalloc (PAGE_SIZE );int ret =0 ; - ret =lseek (fd, start,SEEK_SET ); -if (ret ==-1 ) { +if (lseek (fd, start,SEEK_SET ) != start) {perror ("lseek" ); + ret = -errno; goto out_free; }
Looks fine,
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 crypto: digest: Return -errno if stat() fails
In reply to Andrey SmirnovStrictly speaking, stat() doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'.
--- crypto/digest.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
crypto/digest.c +2 -5
@@ -317,12 +317,9 @@ int digest_file(struct digest *d, const char *filename, const unsigned char *sig) {struct stat st; -int ret; - - ret =stat (filename, &st); -if (ret <0 ) -return ret; +if (stat (filename, &st)) +return -errno;return digest_file_window (d, filename, hash, sig,0 , st.st_size); }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/3] crypto: digest: Return -errno if stat() fails
Quoted 17 lines · Andrey Smirnov
Strictly speaking,
stat()doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'.Signed-off-by Andrey Smirnov <[email protected]>--- crypto/digest.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)crypto/digest.c +0
-1@@ -317,12 +317,9 @@ int digest_file(struct digest *d, const char *filename, const unsigned char *sig) {struct stat st; -int ret;
crypto/digest.c int digest_file(struct digest *d, const char *filename, · line 325
Quoted 10 lines
crypto/digest.c +2
-4- - ret =stat (filename, &st); -if (ret <0 ) -return ret; +if (stat (filename, &st)) +return -errno;return digest_file_window (d, filename, hash, sig,0 , st.st_size); }
Likewise fine,
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 13 lines · Andrey Smirnov
Strictly speaking,
open()doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'.Signed-off-by Andrey Smirnov <[email protected]>--- crypto/digest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)crypto/digest.c +0
-0
crypto/digest.c int digest_file_window(struct digest *d, const char *filename, · line 295
Quoted 8 lines
crypto/digest.c +1
-1@@ -289,7 +289,7 @@ int digest_file_window(struct digest *d, const char *filename, fd =open (filename,O_RDONLY );if (fd <0 ) {perror (filename); -return fd; +return -errno; } buf =memmap (fd,PROT_READ );
Looks fine,
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 7 lines · Andrey Smirnov
Strictly speaking,
open()doesn't return a detailed error code as its return value and it can and should be obtained via 'errno'.Signed-off-by Andrey Smirnov <[email protected]>--- crypto/digest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox