|
From: | Shreenidhi Shedi |
Subject: | Re: cpio improvements and fixes |
Date: | Fri, 3 Sep 2021 12:47:12 +0530 |
Shreenidhi Shedi <yesshedi@gmail.com> ha escrit:
> > [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?
Allow me some time.
> > [PATCH 07/12] Optimize ds_resize logic
[...]
> Shedi: In that case can we do,
There's no use to. x2nrealloc does its job well enough
without any special hints from the caller. Besides, this:
> else
> {
> len <<= 1;
> }
introduces an integer overlow.
> > [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.
I'll remove it, eventually.
> > [PATCH 11/12] Use strtol instead of atoi
[..]
> > - 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?
It would equally suffice for atoi, so there's no need to replace it.
The main advantage of using strto... over atoi is its error detection
capabilities. The usual paradigm is:
char *end;
long n;
errno = 0;
n = strtol (arg, &end, 10);
if (errno || *end || n < 0 || n > INT_MAX)
error (...);
io_block_size = n;
See strtol(3) for details. In this particular case I don't see any
advantage in using strtol.
Regards,
Sergey
[Prev in Thread] | Current Thread | [Next in Thread] |