+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.
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;
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,
main (int argc, char **argv)
{
bool ok = true;
- struct Options flags;
+ struct Options flags = { 0, };
char **file;
int n_files;
int c;
atexit (close_stdout);
- memset (&flags, 0, sizeof flags);
-
flags.n_iterations = DEFAULT_PASSES;
flags.size = -1;
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;
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);
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);
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);
{
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)
{
{
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
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;