Patchwork lib: framework: report warning[s] correctly (LP:#1223736)

login
register
mail settings
Submitter Colin King
Date Sept. 11, 2013, 9:08 a.m.
Message ID <1378890496-5119-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/274201/
State Accepted
Headers show

Comments

Colin King - Sept. 11, 2013, 9:08 a.m.
From: Colin Ian King <colin.king@canonical.com>

Report "warnings" for more than 1 warning, or "warning" for
1 warning. Correcly pluaralise.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Ivan Hu - Sept. 18, 2013, 3:03 a.m.
On 09/11/2013 05:08 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Report "warnings" for more than 1 warning, or "warning" for
> 1 warning. Correcly pluaralise.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index d44fc22..e2b8805 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -319,7 +319,9 @@ static void fwts_framework_format_results(char *buffer, int buflen, fwts_results
>   		buflen -= n;
>   	}
>   	if ((include_zero_results || (results->warning > 0)) && (buflen > 0)) {
> -		n = snprintf(buffer, buflen, "%s%u warnings", n > 0 ? ", " : "", results->warning);
> +		n = snprintf(buffer, buflen, "%s%u warning%s",
> +			n > 0 ? ", " : "", results->warning,
> +			results->warning > 1 ? "s" : "");
>   		buffer += n;
>   		buflen -= n;
>   	}
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Keng-Yu Lin - Oct. 1, 2013, 7:34 a.m.
On Wed, Sep 18, 2013 at 11:03 AM, IvanHu <ivan.hu@canonical.com> wrote:
> On 09/11/2013 05:08 PM, Colin King wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Report "warnings" for more than 1 warning, or "warning" for
>> 1 warning. Correcly pluaralise.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   src/lib/src/fwts_framework.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
>> index d44fc22..e2b8805 100644
>> --- a/src/lib/src/fwts_framework.c
>> +++ b/src/lib/src/fwts_framework.c
>> @@ -319,7 +319,9 @@ static void fwts_framework_format_results(char
>> *buffer, int buflen, fwts_results
>>                 buflen -= n;
>>         }
>>         if ((include_zero_results || (results->warning > 0)) && (buflen >
>> 0)) {
>> -               n = snprintf(buffer, buflen, "%s%u warnings", n > 0 ? ", "
>> : "", results->warning);
>> +               n = snprintf(buffer, buflen, "%s%u warning%s",
>> +                       n > 0 ? ", " : "", results->warning,
>> +                       results->warning > 1 ? "s" : "");
>>                 buffer += n;
>>                 buflen -= n;
>>         }
>>
>
> Acked-by: Ivan Hu <ivan.hu@canonical.com>
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index d44fc22..e2b8805 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -319,7 +319,9 @@  static void fwts_framework_format_results(char *buffer, int buflen, fwts_results
 		buflen -= n;
 	}
 	if ((include_zero_results || (results->warning > 0)) && (buflen > 0)) {
-		n = snprintf(buffer, buflen, "%s%u warnings", n > 0 ? ", " : "", results->warning);
+		n = snprintf(buffer, buflen, "%s%u warning%s",
+			n > 0 ? ", " : "", results->warning,
+			results->warning > 1 ? "s" : "");
 		buffer += n;
 		buflen -= n;
 	}