[Toybox] [TOY] lspci
Felix Janda
felix.janda at posteo.de
Wed Jul 24 11:55:50 PDT 2013
Sandeep Sharma wrote:
[...]
> hi,
> I have some questions actually :-
>
> > > - fd = openat(dirfd, fname, O_RDONLY);
> > > - if (fd < 0) {
> > > - return NULL;
> > > - }
> > > - lseek(fd, offset, SEEK_SET);
> > > + char *buf = calloc(1, nbyte+1);
> > > +
> why calloc and why not __xzalloc__ ? Are not we following
> toybox coding style.
>
> And what if _calloc_ returns NULL. we will be using a NULL buffer, it
> may lead to a potentional crash.
Yes, xzalloc would be preferable. Freeing the memory at some point would also
be nice. I'd even more prefer to have no dynamic allocation in this toy (at
least in the current form) at all. I'm going to post a new version like this
soon but the code is not as clear as the original one.
Felix
1374692150.0
More information about the Toybox
mailing list