From owner-svn-src-stable@freebsd.org Tue Jul 24 05:09:51 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B27B010402F0; Tue, 24 Jul 2018 05:09:51 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 570E47F6D8; Tue, 24 Jul 2018 05:09:51 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28ECA26D59; Tue, 24 Jul 2018 05:09:51 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6O59o4F074965; Tue, 24 Jul 2018 05:09:50 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6O59oWY074964; Tue, 24 Jul 2018 05:09:50 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201807240509.w6O59oWY074964@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 24 Jul 2018 05:09:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r336661 - stable/11/usr.bin/gzip X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/usr.bin/gzip X-SVN-Commit-Revision: 336661 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2018 05:09:52 -0000 Author: delphij Date: Tue Jul 24 05:09:50 2018 New Revision: 336661 URL: https://svnweb.freebsd.org/changeset/base/336661 Log: MFC r336156: Use endian.h le32dec() instead of rolling our own. Suggested by: phk Reviewed by: imp, pfg Differential Revision: https://reviews.freebsd.org/D16192 Modified: stable/11/usr.bin/gzip/gzip.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/gzip/gzip.c ============================================================================== --- stable/11/usr.bin/gzip/gzip.c Tue Jul 24 04:38:11 2018 (r336660) +++ stable/11/usr.bin/gzip/gzip.c Tue Jul 24 05:09:50 2018 (r336661) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); * - make bzip2/compress -v/-t/-l support work as well as possible */ +#include #include #include #include @@ -1016,10 +1017,7 @@ gz_uncompress(int in, int out, char *pre, size_t prele maybe_warnx("truncated input"); goto stop_and_fail; } - origcrc = ((unsigned)z.next_in[0] & 0xff) | - ((unsigned)z.next_in[1] & 0xff) << 8 | - ((unsigned)z.next_in[2] & 0xff) << 16 | - ((unsigned)z.next_in[3] & 0xff) << 24; + origcrc = le32dec(&z.next_in[0]); if (origcrc != crc) { maybe_warnx("invalid compressed" " data--crc error"); @@ -1047,10 +1045,7 @@ gz_uncompress(int in, int out, char *pre, size_t prele maybe_warnx("truncated input"); goto stop_and_fail; } - origlen = ((unsigned)z.next_in[0] & 0xff) | - ((unsigned)z.next_in[1] & 0xff) << 8 | - ((unsigned)z.next_in[2] & 0xff) << 16 | - ((unsigned)z.next_in[3] & 0xff) << 24; + origlen = le32dec(&z.next_in[0]); if (origlen != out_sub_tot) { maybe_warnx("invalid compressed" @@ -1497,7 +1492,7 @@ file_uncompress(char *file, char *outfile, size_t outs goto lose; } infile_newdata(rv); - timestamp = ts[3] << 24 | ts[2] << 16 | ts[1] << 8 | ts[0]; + timestamp = le32dec(&ts[0]); if (header1[3] & ORIG_NAME) { rbytes = pread(fd, name, sizeof(name) - 1, GZIP_ORIGNAME); @@ -2170,16 +2165,10 @@ print_list(int fd, off_t out, const char *outfile, tim maybe_warnx("read of uncompressed size"); else { - usize = buf[4]; - usize |= (unsigned int)buf[5] << 8; - usize |= (unsigned int)buf[6] << 16; - usize |= (unsigned int)buf[7] << 24; + usize = le32dec(&buf[4]); in = (off_t)usize; #ifndef SMALL - crc = buf[0]; - crc |= (unsigned int)buf[1] << 8; - crc |= (unsigned int)buf[2] << 16; - crc |= (unsigned int)buf[3] << 24; + crc = le32dec(&buf[0]); #endif } }