[Toybox] [New Toy] : add udhcpd
Ashwini Sharma
ak.ashwini at gmail.com
Tue Aug 13 00:46:55 PDT 2013
Hi All,
Modified the code to avoid usage of _goto_.
Attached is the updated patch.
regards,
Ashwini
On Tue, Aug 13, 2013 at 1:03 AM, Isaac <ibid.ag at gmail.com> wrote:
> On Mon, Aug 12, 2013 at 06:29:25PM +0900, Ashwini Sharma wrote:
> > Hi Rob,
> >
> > In the continuation to DHCP client sent to you last week, attached here
> > with is the DHCP server implementation.
> >
> > Have a look at the same and let me know for any comments.
> >
> > regards,
> > Ashwini
>
> Note: these are my comments and not Rob's.
>
> I note that not all of the uses of goto are neccessary.
> Here's an example of what I refer to:
>
> if (buffer[0] == '#' || buffer[0] == '\n') goto free_buffer;
> //parse buffer here
> free_buffer:
> free(buffer);
>
> can readily become
> if (buffer[0] != '#' && buffer[0] != '\n') {
> //parse buffer here
> }
> free(buffer);
>
> Of course, for a buffer there's toybuf, which is not to be free()ed.
>
> There will be places where you need to use goto if you don't check
> 3 different variables, but for cases where you aren't jumping out of
> a loop, the if () {} approach makes it much clearer that the code
> is conditionally executed.
>
> Thanks,
> Isaac Dunham
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20130813/4e3064a7/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: udhcpd.c.patch
Type: application/octet-stream
Size: 41413 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20130813/4e3064a7/attachment-0002.obj>
More information about the Toybox
mailing list