[Toybox] [New Toy] : add udhcpd

Isaac ibid.ag at gmail.com
Mon Aug 12 09:03:41 PDT 2013


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

 1376323421.0


More information about the Toybox mailing list