[4/9] xkbtext: fix copy-paste error

Submitted by Konstantin Kharlamov on March 23, 2019, 11:51 p.m.

Details

Message ID 20190323235203.30143-5-Hi-Angel@yandex.ru
State New
Headers show
Series "Fix some of LGTM warnings" ( rev: 1 ) in X.org

Not browsing as part of any series.

Commit Message

Konstantin Kharlamov March 23, 2019, 11:51 p.m.
As can be seen in diff, nOut is always 0 here. The code was likely
copy-pasted from comparisons further below.

Fixes LGTM warning "Comparison is always false because nOut <= 0."

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
---
 xkb/xkbtext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index d2a2567fc..54cca3fb4 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -966,7 +966,7 @@  CopySetLockControlsArgs(XkbDescPtr xkb, XkbAction *action, char *buf, int *sz)
         int nOut = 0;
 
         if (tmp & XkbRepeatKeysMask) {
-            snprintf(tbuf, sizeof(tbuf), "%sRepeatKeys", (nOut > 0 ? "+" : ""));
+            snprintf(tbuf, sizeof(tbuf), "RepeatKeys");
             TryCopyStr(buf, tbuf, sz);
             nOut++;
         }

Comments

> Konstantin Kharlamov <Hi-Angel@yandex.ru> hat am 24. März 2019 um 00:51
> geschrieben:
> 
> 
> As can be seen in diff, nOut is always 0 here. The code was likely
> copy-pasted from comparisons further below.
> 
> Fixes LGTM warning "Comparison is always false because nOut <= 0."
> 
> Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> ---
>  xkb/xkbtext.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
> index d2a2567fc..54cca3fb4 100644
> --- a/xkb/xkbtext.c
> +++ b/xkb/xkbtext.c
> @@ -966,7 +966,7 @@ CopySetLockControlsArgs(XkbDescPtr xkb, XkbAction *action,
> char *buf, int *sz)
>          int nOut = 0;
>  
>          if (tmp & XkbRepeatKeysMask) {
> -            snprintf(tbuf, sizeof(tbuf), "%sRepeatKeys", (nOut > 0 ? "+" :
> ""));
> +            snprintf(tbuf, sizeof(tbuf), "RepeatKeys");
>              TryCopyStr(buf, tbuf, sz);

maybe that can go directly in TryCopyStr() ?

re,
 wh

>              nOut++;
>          }
> -- 
> 2.21.0
> 
> _______________________________________________
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
В Вс, мар 24, 2019 at 22:29, Walter Harms <wharms@bfs.de> 
написал:
> 
> 
>>  Konstantin Kharlamov <Hi-Angel@yandex.ru> hat am 24. März 2019 um 
>> 00:51
>>  geschrieben:
>> 
>> 
>>  As can be seen in diff, nOut is always 0 here. The code was likely
>>  copy-pasted from comparisons further below.
>> 
>>  Fixes LGTM warning "Comparison is always false because nOut <= 0."
>> 
>>  Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
>>  ---
>>   xkb/xkbtext.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>>  diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
>>  index d2a2567fc..54cca3fb4 100644
>>  --- a/xkb/xkbtext.c
>>  +++ b/xkb/xkbtext.c
>>  @@ -966,7 +966,7 @@ CopySetLockControlsArgs(XkbDescPtr xkb, 
>> XkbAction *action,
>>  char *buf, int *sz)
>>           int nOut = 0;
>> 
>>           if (tmp & XkbRepeatKeysMask) {
>>  -            snprintf(tbuf, sizeof(tbuf), "%sRepeatKeys", (nOut > 0 
>> ? "+" :
>>  ""));
>>  +            snprintf(tbuf, sizeof(tbuf), "RepeatKeys");
>>               TryCopyStr(buf, tbuf, sz);
> 
> maybe that can go directly in TryCopyStr() ?

Thanks, good point! Done.