Thanks Sergey for the feedback and review. Following are my answers for your questions and comments.
Shedi: Agree with you. But we might include a header in a .h file and include both headers in a C file. This is just an attempt to prevent that situation. Just being defensive here.
> [PATCH 03/12] Format specifier fixes
> Needs more investigation (the use of %zu is not portable)
Shedi: Shall I just do something like this: fptintf(stderr, "nlink = %u ...", (unsigned) h->c_nlink, ...); instead?
> [PATCH 05/12] Enclose sizeof parameter in braces
> Purely aesthetic change and, as such, arguable. In my opinion, redundant
> braces harm readability.
Shree: Agree. It's your call, I'm not sure about the coding standard followed in cpio. I'm comfortable with having braces with sizeof.
> [PATCH 07/12] Optimize ds_resize logic
> That's wrong. The fact that x2nrealloc succeeded means only that
> the allocated block is ~50% bigger than the previously used one,
> but this does not imply its size is sufficient to accomodate len
> bytes. Hence the need for the loop.
Shedi: In that case can we do,
void ds_resize (dynamic_string *string, size_t len)
{
len += string->ds_idx;
if (len >= string->ds_size)
{
len -= string->ds_size;
if (len == 0)
{
len = 1;
}
else
{
len <<= 1;
}
string->ds_string = x2nrealloc (string->ds_string, &string->ds_size,
len);
}
}
> [PATCH 08/12] Reformat & refactor userspec.c
> What's the purpose of this?
Shedi: Alloca is a deprecated function in C99. Static analyzers throw a warning for alloca usage. So, I started modifying code to remove alloca usage and ended up refactoring it.
> [PATCH 09/12] Use destination size in strncpy to avoid
> 'stringop-overflow' warning from gcc
> tar_hdr->name is TARNAMESIZE bytes wide. The copying is protected by
> 'if (name_len <= TARNAMESIZE)', which rules out any possibility of
> overflow.
Shedi: Agree with you here and the code is correct, gcc throws this warning. I tried to keep gcc happy and suppress that warning.
My changes are appropriate and the original version is right too but gcc doesn't like it.
> [PATCH 11/12] Use strtol instead of atoi
> The patch contains lots of whitespace changes, which makes it hard to
> see the actual purpose. Nevertheless:
> - io_block_size = atoi (arg);
> + io_block_size = (int) strtol (arg, NULL, 10);
Shedi: The next line has a `if (io_block_size < 1)` that should suffice right?
Thanks,
Shedi