[U-Boot] net: Add \n before warning message so it prints on a new line.

Submitted by Philip Balister on Sept. 7, 2011, 11:57 a.m.

Details

Message ID 1315396670-22889-1-git-send-email-philip@opensdr.com
State Accepted
Commit a9a730e0bc18535597d15ce47964824baf220c94
Headers show

Commit Message

Philip Balister Sept. 7, 2011, 11:57 a.m.
Signed-off-by: Philip Balister <philip@opensdr.com>
---
 net/eth.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Albert ARIBAUD Sept. 8, 2011, 3:01 p.m.
Hi Philip,

Le 07/09/2011 13:57, Philip Balister a écrit :
> Signed-off-by: Philip Balister<philip@opensdr.com>
> ---
>   net/eth.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/eth.c b/net/eth.c
> index dbd1e2d..67a8039 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -305,7 +305,7 @@ int eth_initialize(bd_t *bis)
>   				puts("\nWarning: eth device name has a space!\n");
>
>   			if (eth_write_hwaddr(dev, "eth", eth_number))
> -				puts("Warning: failed to set MAC address\n");
> +				puts("\nWarning: failed to set MAC address\n");

I believe warning messages with \n on more than one end are frowned upon.

>   			eth_number++;
>   			dev = dev->next;

Amicalement,
Philip Balister Sept. 8, 2011, 3:04 p.m.
On 09/08/2011 11:01 AM, Albert ARIBAUD wrote:
> Hi Philip,
>
> Le 07/09/2011 13:57, Philip Balister a écrit :
>> Signed-off-by: Philip Balister<philip@opensdr.com>
>> ---
>> net/eth.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/eth.c b/net/eth.c
>> index dbd1e2d..67a8039 100644
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -305,7 +305,7 @@ int eth_initialize(bd_t *bis)
>> puts("\nWarning: eth device name has a space!\n");
>>
>> if (eth_write_hwaddr(dev, "eth", eth_number))
>> - puts("Warning: failed to set MAC address\n");
>> + puts("\nWarning: failed to set MAC address\n");
>
> I believe warning messages with \n on more than one end are frowned upon.

Look closely at the patch, the warning message above has to do the same 
thing. Without the leading \n on the message, it prints directly after 
the ethernet chip name, with no space. This is not right. I chose to 
copy the existing code, rather than add a leading space.

Philip

>
>> eth_number++;
>> dev = dev->next;
>
> Amicalement,
Albert ARIBAUD Sept. 8, 2011, 4:08 p.m.
Le 08/09/2011 17:04, Philip Balister a écrit :
> On 09/08/2011 11:01 AM, Albert ARIBAUD wrote:
>> Hi Philip,
>>
>> Le 07/09/2011 13:57, Philip Balister a écrit :
>>> Signed-off-by: Philip Balister<philip@opensdr.com>
>>> ---
>>> net/eth.c | 2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/net/eth.c b/net/eth.c
>>> index dbd1e2d..67a8039 100644
>>> --- a/net/eth.c
>>> +++ b/net/eth.c
>>> @@ -305,7 +305,7 @@ int eth_initialize(bd_t *bis)
>>> puts("\nWarning: eth device name has a space!\n");
>>>
>>> if (eth_write_hwaddr(dev, "eth", eth_number))
>>> - puts("Warning: failed to set MAC address\n");
>>> + puts("\nWarning: failed to set MAC address\n");
>>
>> I believe warning messages with \n on more than one end are frowned upon.
>
> Look closely at the patch, the warning message above has to do the same
> thing. Without the leading \n on the message, it prints directly after
> the ethernet chip name, with no space. This is not right. I chose to
> copy the existing code, rather than add a leading space.

Just because original code has an error does not make it right to 
reproduce it. :)

More seriously, heterogeneous \n placement makes it complicated to get 
and keep printing right -- for instance here the warning messages have a 
trailing \n but the code loop adds one at the end.

I would prefer that the code do a first loop (while dev!= eth_devices) 
to try and set up ethernet devices, emitting simple "warning\n" messages 
as needed, then a second loop (for dev=0 to eth_number-1) to print a 
summary of the final list of eth devices found and initialized.

Amicalement,

Patch hide | download patch | download mbox

diff --git a/net/eth.c b/net/eth.c
index dbd1e2d..67a8039 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -305,7 +305,7 @@  int eth_initialize(bd_t *bis)
 				puts("\nWarning: eth device name has a space!\n");
 
 			if (eth_write_hwaddr(dev, "eth", eth_number))
-				puts("Warning: failed to set MAC address\n");
+				puts("\nWarning: failed to set MAC address\n");
 
 			eth_number++;
 			dev = dev->next;