01.05.2020 16:28, Andrew Rybchenko пишет:
> On 4/27/20 12:57 PM, Ivan Dyukov wrote:
>> Signed-off-by: Ivan Dyukov <i.dyu...@samsung.com>
>> ---
>>   doc/guides/sample_app_ug/link_status_intr.rst | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/guides/sample_app_ug/link_status_intr.rst 
>> b/doc/guides/sample_app_ug/link_status_intr.rst
>> index 5283be8b7..6ebc707b7 100644
>> --- a/doc/guides/sample_app_ug/link_status_intr.rst
>> +++ b/doc/guides/sample_app_ug/link_status_intr.rst
>> @@ -177,7 +177,8 @@ An example callback function that has been 
>> written as indicated below.
>>               printf("Failed to get port %d link status: %s\n\n",
>>                      port_id, rte_strerror(-ret));
>>           } else if (link.link_status) {
>> -            printf("Port %d Link Up - speed %u Mbps - %s\n\n", 
>> port_id, (unsigned)link.link_speed,
>> +            printf("Port %d Link Up - speed %u%s - %s\n\n", port_id, 
>> (unsigned)link.link_speed,
>> +                  (link.link_speed == UINT32_MAX) ? ("(UNKNOWN)") : 
>> (" Mbps"),
>>                     (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? 
>> ("full-duplex") : ("half-duplex"));
>>           } else
>>               printf("Port %d Link Down\n\n", port_id);
>>
>
> I think that 0 looks nicer than UINT32_MAX when printed as integer
> keeping in mind that it is unknown.
>
zero will mislead developers about real value of the link_speed. 
therefore we should print real value of the speed or print nothing. e.g.

    if (link.link_speed == UINT32_MAX)

         printf("Port %d Link Up - speed UNKNOWN - %s\n\n", port_id,
                    (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? 
("full-duplex") : ("half-duplex"));
    else

         printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, 
link.link_speed,

                     (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? 
("full-duplex") : ("half-duplex"));

Reply via email to