Re: [PATCH] rt-tests: hackbench: drop incorrect and unnecessary usage of optind

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 5 Apr 2024, Sebastian Andrzej Siewior wrote:

> On 2024-04-02 19:46:59 [+0200], Nam Cao wrote:
> > Variable "optind" is used as the last argument of getopt_long(). This
> > means it "is set to the index of the long option relative to longopts"
> > (from man page). NULL check is then performed on argv[optind], which is
> > not valid, because in this case, optind is not an index to argv[].
> > 
> > There is another "optind" which is a global variable, which actually
> > holds the index to argv[]. This is likely the actual intention here. By
> > locally define another "optind", the "real optind" is shadowed in this
> > scope.
> > 
> > Furthermore, the original optind "is the index of the next element to
> > be processed in argv" (from man page), not the index to the current
> > element. So doing NULL-check on argv[optind] with the "original optind"
> > is also not valid.
> > 
> > There is no reason to do this NULL-check, since argv[optind] is not even
> > read. Only optarg is read, which is never a NULL pointer in this case.
> > 
> > Delete this incorrect and unnecessary "optind".
> > 
> > Signed-off-by: Nam Cao <namcao@xxxxxxxxxxxxx>
> 
> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> 
> Sebastian
> 
> 

Added your Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
to the patch, thanks





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux