[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "ls -l": Avoid unnecessary getxattr() overhead
From: |
Jim Meyering |
Subject: |
Re: "ls -l": Avoid unnecessary getxattr() overhead |
Date: |
Fri, 17 Feb 2012 10:18:46 +0100 |
Bernhard Voelker wrote:
...
>> +static dev_t selinux_challenged_device;
>
> Having worked with different compilers, I would rather like to see such
> variables to be initialized.
...
Depending on static-scoped variables to be initialized to 0
is so fundamental, and has been that way forever, if
you've seen a compiler that gets it wrong, it could not have
been good for anything other than (poor) demonstration purposes.
In any declaration like "static int VAR = 0;" the "= 0" part is
strictly optional, even from a let's-be-ultra-portable standpoint.
At least as far as I know. Can you provide details on a compiler
that gets that wrong?
You can argue that it makes the code slightly more readable,
especially if one fails to notice the "static" part.
I just checked and see that there are plenty of instances in coreutils:
git grep -E 'static.* = (0|NULL);'
but most are in the dustier corners, and there are well over 200
that omit the initializer.
src/cat.c:static int newlines2 = 0;
src/csplit.c:static struct buffer_record *head = NULL;
src/csplit.c:static char *hold_area = NULL;
src/csplit.c:static size_t hold_count = 0;
src/csplit.c:static uintmax_t last_line_number = 0;
src/csplit.c:static uintmax_t current_line = 0;
src/csplit.c:static char *volatile filename_space = NULL;
src/csplit.c:static char const *volatile prefix = NULL;
src/csplit.c:static char *volatile suffix = NULL;
src/csplit.c:static unsigned int volatile files_created = 0;
src/csplit.c:static FILE *output_stream = NULL;
src/csplit.c:static char *output_filename = NULL;
src/csplit.c: static struct buffer_record *prev_buf = NULL;
src/csplit.c: static size_t control_allocated = 0; /* Total space allocated.
*/
src/csplit.c: static uintmax_t last_val = 0;
src/dd.c:static char const *input_file = NULL;
src/dd.c:static char const *output_file = NULL;
src/dd.c:static size_t input_blocksize = 0;
src/dd.c:static size_t output_blocksize = 0;
src/dd.c:static size_t conversion_blocksize = 0;
src/dd.c:static uintmax_t skip_records = 0;
src/dd.c:static size_t skip_bytes = 0;
src/dd.c:static uintmax_t seek_records = 0;
src/dd.c:static uintmax_t seek_bytes = 0;
src/dd.c:static size_t max_bytes = 0;
src/dd.c:static int conversions_mask = 0;
src/dd.c:static int input_flags = 0;
src/dd.c:static int output_flags = 0;
src/dd.c:static int status_flags = 0;
src/dd.c:static uintmax_t w_partial = 0;
src/dd.c:static uintmax_t w_full = 0;
src/dd.c:static uintmax_t r_partial = 0;
src/dd.c:static uintmax_t r_full = 0;
src/dd.c:static uintmax_t w_bytes = 0;
src/dd.c:static uintmax_t r_truncate = 0;
src/dd.c:static size_t oc = 0;
src/dd.c:static size_t col = 0;
src/dd.c: static size_t pending_spaces = 0;
src/du.c:static char const *time_style = NULL;
src/du.c:static char const *time_format = NULL;
src/factor.c:static mpz_t *factor = NULL;
src/factor.c:static size_t nfactors_found = 0;
src/factor.c:static size_t nfactors_allocated = 0;
src/fold.c: static char *line_out = NULL;
src/fold.c: static size_t allocated_out = 0;
src/id.c:static int just_context = 0;
src/id.c:static security_context_t context = NULL;
src/install.c:static int selinux_enabled = 0;
src/ls.c:static struct color_ext_type *color_ext_list = NULL;
src/nl.c:static struct re_pattern_buffer *current_regex = NULL;
src/nl.c:static char *header_del = NULL;
src/nl.c:static char *body_del = NULL;
src/nl.c:static char *footer_del = NULL;
src/nl.c:static char *print_no_line_fmt = NULL;
src/nl.c: static intmax_t blank_lines = 0; /* Consecutive blank lines so
far. */
src/od.c:static uintmax_t n_bytes_to_skip = 0;
src/pinky.c: static time_t now = 0;
src/pr.c:static int chars_per_margin = 0;
src/pr.c:static uintmax_t first_page_number = 0;
src/pr.c:static int files_ready_to_read = 0;
src/pr.c:static int total_files = 0;
src/pr.c:static int col_sep_length = 0;
src/ptx.c:static const char *break_file = NULL; /* name of the 'Break
chars' file */
src/ptx.c:static const char *only_file = NULL; /* name of the 'Only
words' file */
src/ptx.c:static const char *ignore_file = NULL; /* name of the 'Ignore
words' file */
src/tac.c: static size_t bytes_in_buffer = 0;
src/tac.c: static char *tempfile = NULL;
src/test.c: static int test_error_return = 0;
src/tsort.c:static struct item *head = NULL;
src/tsort.c:static struct item *zeros = NULL;
src/tsort.c:static struct item *loop = NULL;
src/tsort.c:static size_t n_strings = 0;
- Re: "ls -l": Avoid unnecessary getxattr() overhead, (continued)
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Pádraig Brady, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/10
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/11
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/16
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Bernhard Voelker, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead,
Jim Meyering <=
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Bernhard Voelker, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Bernhard Voelker, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Bernhard Voelker, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Bernhard Voelker, 2012/02/17
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/18
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/19
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Pádraig Brady, 2012/02/19