The branch main has been updated by tsoome:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2c52512caf6ec10f49038e6884b9c2aea905cc4e

commit 2c52512caf6ec10f49038e6884b9c2aea905cc4e
Author:     Toomas Soome <[email protected]>
AuthorDate: 2021-01-11 19:42:44 +0000
Commit:     Toomas Soome <[email protected]>
CommitDate: 2021-01-11 22:56:35 +0000

    pnglite: should use ntohl
    
    Replace manual conversion with ntohl()
---
 contrib/pnglite/pnglite.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/contrib/pnglite/pnglite.c b/contrib/pnglite/pnglite.c
index e3cc2f866c6f..f517b6bdcaa5 100644
--- a/contrib/pnglite/pnglite.c
+++ b/contrib/pnglite/pnglite.c
@@ -52,12 +52,12 @@ file_read(png_t *png, void *out, size_t size, size_t numel)
 static int
 file_read_ul(png_t *png, unsigned *out)
 {
-       uint8_t buf[4];
+       uint32_t buf;
 
-       if (file_read(png, buf, 1, 4) != 4)
+       if (file_read(png, &buf, 1, 4) != 4)
                return (PNG_FILE_ERROR);
 
-       *out = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
+       *out = ntohl(buf);
 
        return (PNG_NO_ERROR);
 }
@@ -65,14 +65,7 @@ file_read_ul(png_t *png, unsigned *out)
 static unsigned
 get_ul(uint8_t *buf)
 {
-       unsigned result;
-       uint8_t foo[4];
-
-       memcpy(foo, buf, 4);
-
-       result = (foo[0]<<24) | (foo[1]<<16) | (foo[2]<<8) | foo[3];
-
-       return (result);
+       return (ntohl(*(uint32_t *)buf));
 }
 
 static int
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to