* src/ls.c (quote_name): Use initializer rather than memset to

initialize an object to zero.  This is easier to read and is less
likely to introduce an runtime error due to a mixup.  It causes
gcc -W to issue a warning, but you can work around this by
appending -Wno-missing-field-initializers.
* src/pathchk.c (portable_chars_only): Likewise.
* src/shred.c (main): Likewise.
* src/stty.c (main): Likewise.
* src/tr.c (card_of_complement): Likewise.
* src/wc.c (wc): Likewise.
This commit is contained in:
Paul Eggert committed 2006-10-10 22:57:07 +00:00
1 parent 489ff7f0cd
commit e245a66054
7 files changed
+26 -22

No files matched your search

+13
View File
@@ -1,3 +1,16 @@
2006-10-10 Paul Eggert <eggert@cs.ucla.edu>
* src/ls.c (quote_name): Use initializer rather than memset to
initialize an object to zero. This is easier to read and is less
likely to introduce an runtime error due to a mixup. It causes
gcc -W to issue a warning, but you can work around this by
appending -Wno-missing-field-initializers.
* src/pathchk.c (portable_chars_only): Likewise.
* src/shred.c (main): Likewise.
* src/stty.c (main): Likewise.
* src/tr.c (card_of_complement): Likewise.
* src/wc.c (wc): Likewise.
2006-10-09 Paul Eggert <eggert@cs.ucla.edu>
* src/sort.c (usage): Mention again that sort fields are origin 1.
+1 -2
View File
@@ -3604,8 +3604,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
reach its end, replacing each non-printable multibyte
character with a single question mark. */
{
mbstate_t mbstate;
memset (&mbstate, 0, sizeof mbstate);
mbstate_t mbstate = { 0, };
do
{
wchar_t wc;
+2 -5
View File
@@ -200,11 +200,8 @@ portable_chars_only (char const *file, size_t filelen)
if (*invalid)
{
mbstate_t mbstate;
size_t charlen;
memset (&mbstate, 0, sizeof mbstate);
charlen = mbrlen (invalid, filelen - validlen, &mbstate);
mbstate_t mbstate = { 0, };
size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate);
error (0, 0,
_("nonportable character %s in file name %s"),
quotearg_n_style_mem (1, locale_quoting_style, invalid,
+1 -3
View File
@@ -1091,7 +1091,7 @@ int
main (int argc, char **argv)
{
bool ok = true;
struct Options flags;
struct Options flags = { 0, };
char **file;
int n_files;
int c;
@@ -1106,8 +1106,6 @@ main (int argc, char **argv)
atexit (close_stdout);
memset (&flags, 0, sizeof flags);
flags.n_iterations = DEFAULT_PASSES;
flags.size = -1;
+7 -8
View File
@@ -729,7 +729,10 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\
int
main (int argc, char **argv)
{
struct termios mode;
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
struct termios mode = { 0, };
enum output_type output_type;
int optc;
int argi = 0;
@@ -840,9 +843,6 @@ main (int argc, char **argv)
else
device_name = _("standard input");
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
memset (&mode, 0, sizeof (mode));
if (tcgetattr (STDIN_FILENO, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
@@ -1002,7 +1002,9 @@ main (int argc, char **argv)
if (require_set_attr)
{
struct termios new_mode;
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
struct termios new_mode = { 0, };
if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
@@ -1014,9 +1016,6 @@ main (int argc, char **argv)
this partial failure, get the current terminal attributes and
compare them to the requested ones. */
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
memset (&new_mode, 0, sizeof (new_mode));
if (tcgetattr (STDIN_FILENO, &new_mode))
error (EXIT_FAILURE, errno, "%s", device_name);
+1 -2
View File
@@ -1177,9 +1177,8 @@ card_of_complement (struct Spec_list *s)
{
int c;
int cardinality = N_CHARS;
bool in_set[N_CHARS];
bool in_set[N_CHARS] = { 0, };
memset (in_set, 0, sizeof in_set);
s->state = BEGIN_STATE;
while ((c = get_next (s, NULL)) != -1)
{
+1 -2
View File
@@ -273,7 +273,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
{
bool in_word = false;
uintmax_t linepos = 0;
mbstate_t state;
mbstate_t state = { 0, };
uintmax_t last_error_line = 0;
int last_error_errno = 0;
# if SUPPORT_OLD_MBRTOWC
@@ -289,7 +289,6 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
const size_t prev = 0;
# endif
memset (&state, 0, sizeof (mbstate_t));
while ((bytes_read = safe_read (fd, buf + prev, BUFFER_SIZE - prev)) > 0)
{
const char *p;