public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] net:Fix potential empty DHCP Parameter Request List
Date: Fri, 22 Oct 2010 16:06:44 -0400	[thread overview]
Message-ID: <201010221606.44818.vapier@gentoo.org> (raw)
In-Reply-To: <1287736585-32489-1-git-send-email-r64343@freescale.com>

On Friday, October 22, 2010 04:36:25 Jason Liu wrote:
> From: Gray Remlin <g_remlin@rocketmail.com>
> 
> Can't get IP address with dhcp due to the dhcp server not
> allow the empty param list request under some network env
> 
> --- a/net/bootp.c
> +++ b/net/bootp.c
> @@ -417,9 +417,19 @@ static int DhcpExtended (u8 * e, int message_type,
> IPaddr_t ServerID, IPaddr_t R return x - start;
>  #endif
> 
> +#if defined(CONFIG_BOOTP_SUBNETMASK) || \
> +    defined(CONFIG_BOOTP_TIMEOFFSET) || \
> +    defined(CONFIG_BOOTP_GATEWAY) || \
> +    defined(CONFIG_BOOTP_DNS) || \
> +    defined(CONFIG_BOOTP_HOSTNAME) || \
> +    defined(CONFIG_BOOTP_BOOTFILESIZE) || \
> +    defined(CONFIG_BOOTP_BOOTPATH) || \
> +    defined(CONFIG_BOOTP_NISDOMAIN) || \
> +    defined(CONFIG_BOOTP_NTPSERVER)
>  	*e++ = 55;		/* Parameter Request List */
>  	 cnt = e++;		/* Pointer to count of requested items */
>  	*cnt = 0;
> +#endif

this list is pretty ugly and prone to breakage.  how about having the code 
back itself up and let gcc optimize things away ?  two ways of doing this ...

(1) after the current ifdef list and before the "*e++ = 255;", add like:
	/* no options, so back up to avoid sending an empty request list */
	if (*cnt == 0)
		e -= 2;

(2) add a "bool empty_list" to this func.  where we set "*cnt = 0", do:
	empty_list = true;
then in every ifdef currently, add:
	empty_list = false;
and at the end, do:
	/* no options, so back up to avoid sending an empty request list */
	if (empty_list)
		e -= 2;
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101022/fa87c00b/attachment.pgp 

  parent reply	other threads:[~2010-10-22 20:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  8:36 [U-Boot] [PATCH 1/1] net:Fix potential empty DHCP Parameter Request List Jason Liu
2010-10-22  9:31 ` Wolfgang Denk
2010-10-22 11:48   ` Jason Liu
2010-10-22 12:04     ` Wolfgang Denk
2010-10-22 20:06 ` Mike Frysinger [this message]
2010-11-14  3:58   ` Jason Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201010221606.44818.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox