Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 02 Apr 2014 23:43:19 -0700
From:      Xin Li <delphij@delphij.net>
To:        Bruce Evans <brde@optusnet.com.au>, Xin LI <delphij@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r264059 - head/bin/dd
Message-ID:  <533D0307.6090509@delphij.net>
In-Reply-To: <20140403150420.H959@besplex.bde.org>
References:  <201404030055.s330tGCI070764@svn.freebsd.org> <20140403150420.H959@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------070702070804010603030108
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 4/2/14, 9:45 PM, Bruce Evans wrote:
> On Thu, 3 Apr 2014, Xin LI wrote:
> 
>> Log: Implement GNU's extension of 'status' operand.  The GNU
>> syntax is borrowed where syntax status=noxfer means no transfer
>> statistics and status=none means no status information at all.
>> 
>> This feature is useful because the statistics information can 
>> sometimes be annoying, and redirecting stderr to /dev/null would 
>> mean error messages also gets silenced.
>> 
>> Obtained from:    OpenBSD MFC after:    2 weeks ... Modified:
>> head/bin/dd/dd.h 
>> ==============================================================================
>>
>>
>> 
- --- head/bin/dd/dd.h    Wed Apr  2 23:07:15 2014    (r264058)
>> +++ head/bin/dd/dd.h    Thu Apr  3 00:55:16 2014    (r264059) @@
>> -68,32 +68,35 @@ typedef struct { } STAT;
>> 
>> /* Flags (in ddflags). */ -#define    C_ASCII        0x00001 
>> -#define    C_BLOCK        0x00002
> 
> The table should have been reformatted separately, or better not at
> all.
> 
>> -#define    C_BS        0x00004 -#define    C_CBS        0x00008 
>> -#define    C_COUNT        0x00010 -#define    C_EBCDIC
>> 0x00020 -#define    C_FILES        0x00040 -#define    C_IBS
>> 0x00080 -#define    C_IF        0x00100 -#define    C_LCASE
>> 0x00200 -#define    C_NOERROR    0x00400 -#define    C_NOTRUNC
>> 0x00800 -#define    C_OBS        0x01000 -#define    C_OF
>> 0x02000 -#define    C_OSYNC        0x04000 -#define    C_PAREVEN
>> 0x08000 -#define    C_PARNONE    0x100000
> 
> The previous formatting was not too good, and obfuscated a bug
> here. 4 bits are unused.  Someone added this bug together with many
> others in 2004, and I missed it then when I committed a fix for the
> others. Most of the bugs that I fixed were unsorting of the table
> by adding to its end.  Insertion sort tends to give large churn of
> the table by changing all the numbers, but for the 2004 fix there
> wasn't much churn except relative to the unsorted version because
> all the changes were near the end.
> 
>> -#define    C_PARODD    0x200000 -#define    C_PARSET
>> 0x400000 -#define    C_SEEK        0x800000 -#define    C_SKIP
>> 0x1000000 -#define    C_SPARSE    0x2000000 -#define    C_SWAB
>> 0x4000000 -#define    C_SYNC        0x8000000 -#define    C_UCASE
>> 0x10000000 -#define    C_UNBLOCK    0x20000000 -#define    C_FILL
>> 0x40000000 +#define    C_ASCII        0x000000001 +#define
>> C_BLOCK        0x000000002 +#define    C_BS        0x000000004 
>> +#define    C_CBS        0x000000008 +#define    C_COUNT
>> 0x000000010 +#define    C_EBCDIC    0x000000020 +#define
>> C_FILES        0x000000040 +#define    C_IBS        0x000000080 
>> +#define    C_IF        0x000000100 +#define    C_LCASE
>> 0x000000200 +#define    C_NOERROR    0x000000400 +#define
>> C_NOTRUNC    0x000000800 +#define    C_OBS        0x000001000 
>> +#define    C_OF        0x000002000 +#define    C_OSYNC
>> 0x000004000 +#define    C_PAREVEN    0x000008000 +#define
>> C_PARNONE    0x000100000 +#define    C_PARODD    0x000200000 
>> +#define    C_PARSET    0x000400000 +#define    C_SEEK
>> 0x000800000 +#define    C_SKIP        0x001000000 +#define
>> C_SPARSE    0x002000000 +#define    C_SWAB        0x004000000 
>> +#define    C_SYNC        0x008000000 +#define    C_UCASE
>> 0x010000000 +#define    C_UNBLOCK    0x020000000
> 
> Unsorting of the table continued from here after I stopped policing
> the order.
> 
>> +#define    C_FILL        0x040000000 +#define    C_STATUS
>> 0x080000000
> 
> The above 2 unsorted entries are old, but reformatting in this
> commit obfuscates the change.
> 
>> +#define    C_NOXFER    0x100000000 +#define    C_NOINFO
>> 0x200000000
> 
> Latest unsorting.

Will it be an improvement if we have the attached change committed?
Basically it redo the sort and use 1 <<'s instead of hardcoded heximal
numbers.

> 
> The 2 values above UINT_MAX also won't compile with compilers that
> warn that 'integer constant is too large for "long" type'.  Mainly
> gcc
without
> -std=c99.  clang is too incompatible to warn about this even with 
> -std=c89 -Wall.  The fix is not to further churn the table by
> adding a ULL suffix to all entries.

Cheers,
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJTPQMHAAoJEJW2GBstM+ns1AAP+wY2LrODW+ouu1crQ8fyxf+g
Naql1NNZyaCLMnhNHGlA0PI1F/EaP/F6RTX12z+yQ/d1xuS4B7BnffXZSxsWIT5y
Hl82p4oq+ZuzuWd0dJ6yRqh98fASOflwogvAdV1SzU5ElaKXX+jUVDcKXFeB3jkz
o/Hv6MQg+LUl0th2ZG5Khox25eQyX9q6whFNRPm8KqnYPP0HXBqPtJMLFAh/eMp6
bmiWbWrQtmLgOHXepa/PLrTmjbYJdef28EL6JWINa7hh2UyndihM5xAI3y2L6dTK
WBBVNhH1dLIgDjme4t7j3tRDZuPaYxyI5ysTuAuDj4ycAzDI+e81E2iSNlfXJskW
i8iTOYQl+C3gg1JWLkPaL4B+RupJXEIDUgkLw2f/cpZPRKz1tfteGKWu26rlPTzA
6aoKaXyy4HL9tKY0I3wrIEcAtg7p95PKuidKWgWYE0U+OhPAOPDCXFC1t74KKR3d
sYDhKvELuhLv1jDT3mnUntKj0LXgLXwSiJDNoqXsa6b0YC6QX+b2uyGpzzxFxoHy
3GPk9Oq/gPF4t8n2m7N7jB6GAjL2IMQBvumrXgUFtL6noGbaesMr/02GlLtsa+cW
fDYH5w1xfdZ4AWPmqiIjWJIoBK6ToQueF5/ggjF9/7xZ2yXVJbIarbmygs2K99TQ
HvuWoapWq04vD4f3g303
=R4Fd
-----END PGP SIGNATURE-----

--------------070702070804010603030108
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
 name="dd.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dd.diff"

Index: bin/dd/dd.h
===================================================================
--- bin/dd/dd.h	(revision 264067)
+++ bin/dd/dd.h	(working copy)
@@ -68,35 +68,35 @@ typedef struct {
 } STAT;
 
 /* Flags (in ddflags). */
-#define	C_ASCII		0x00000001
-#define	C_BLOCK		0x00000002
-#define	C_BS		0x00000004
-#define	C_CBS		0x00000008
-#define	C_COUNT		0x00000010
-#define	C_EBCDIC	0x00000020
-#define	C_FILES		0x00000040
-#define	C_IBS		0x00000080
-#define	C_IF		0x00000100
-#define	C_LCASE		0x00000200
-#define	C_NOERROR	0x00000400
-#define	C_NOTRUNC	0x00000800
-#define	C_OBS		0x00001000
-#define	C_OF		0x00002000
-#define	C_OSYNC		0x00004000
-#define	C_PAREVEN	0x00008000
-#define	C_PARNONE	0x00010000
-#define	C_PARODD	0x00020000
-#define	C_PARSET	0x00040000
-#define	C_SEEK		0x00080000
-#define	C_SKIP		0x00100000
-#define	C_SPARSE	0x00200000
-#define	C_SWAB		0x00400000
-#define	C_SYNC		0x00800000
-#define	C_UCASE		0x01000000
-#define	C_UNBLOCK	0x02000000
-#define	C_FILL		0x04000000
-#define	C_STATUS	0x08000000
-#define	C_NOXFER	0x10000000
-#define	C_NOINFO	0x20000000
+#define	C_ASCII		(1 <<  0)
+#define	C_BLOCK		(1 <<  1)
+#define	C_BS		(1 <<  2)
+#define	C_CBS		(1 <<  3)
+#define	C_COUNT		(1 <<  4)
+#define	C_EBCDIC	(1 <<  5)
+#define	C_FILES		(1 <<  6)
+#define	C_FILL		(1 <<  7)
+#define	C_IBS		(1 <<  8)
+#define	C_IF		(1 <<  9)
+#define	C_LCASE		(1 << 10)
+#define	C_NOERROR	(1 << 11)
+#define	C_NOINFO	(1 << 12)
+#define	C_NOTRUNC	(1 << 13)
+#define	C_NOXFER	(1 << 14)
+#define	C_OBS		(1 << 15)
+#define	C_OF		(1 << 16)
+#define	C_OSYNC		(1 << 17)
+#define	C_PAREVEN	(1 << 18)
+#define	C_PARNONE	(1 << 19)
+#define	C_PARODD	(1 << 20)
+#define	C_PARSET	(1 << 21)
+#define	C_SEEK		(1 << 22)
+#define	C_SKIP		(1 << 23)
+#define	C_SPARSE	(1 << 24)
+#define	C_STATUS	(1 << 25)
+#define	C_SWAB		(1 << 26)
+#define	C_SYNC		(1 << 27)
+#define	C_UCASE		(1 << 28)
+#define	C_UNBLOCK	(1 << 29)
 
 #define	C_PARITY	(C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET)

--------------070702070804010603030108--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?533D0307.6090509>