Thread (71 messages) flat view 71 messages, 4 authors, 2016-07-06

Re: [PATCH 3/4] dir: introduce file_size() to check the size of file

From: Christian Couder <hidden>
Date: 2016-06-16 02:19:48

On Wed, Jun 8, 2016 at 10:13 AM, Eric Sunshine [off-list ref] wrote:
I think this would be clearer if you instead added a function to
bisect--helper.c which operates at a semantically higher level than
what you have here (and drop this file_size() function). Specifically,
add a function which tells you precisely what you want to know:
whether the file exists and has non-zero size. For instance, in
bisect--helper.c:

    static int file_empty_or_missing(const char *path)
    {
        struct stat st;
        return stat(...) < 0 || st.st_size == 0;
    }

Or, if you have more cases where you want to know that it exists with
non-zero size, then name it file_non_empty() and reverse the sense of
the return value.
After a quick grep it seemed to me that there are a few places were we
stat a file just to get its size, so I suggested the file_size()
because it could help refactor other parts of the code.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help