aligrudi / neatvi

A small vi/ex editor for editing UTF-8 text
http://litcave.rudi.ir/
324 stars 27 forks source link

Minor warnings #59

Closed polluks closed 1 year ago

polluks commented 1 year ago

cc -c -Wall -O2 vi.c
vi.c: In function 'vi_motion':
vi.c:546:32: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 254 [-Wformat-truncation=]
   snprintf(kw, sizeof(kw), "\\<%s\\>", cw);
                                ^~      ~~
vi.c:546:3: note: 'snprintf' output between 5 and 260 bytes into a destination of size 256
   snprintf(kw, sizeof(kw), "\\<%s\\>", cw);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vi.c: In function 'vc_gotopath':
vi.c:1112:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 254 [-Wformat-truncation=]
  snprintf(ex, sizeof(ex), "e %s", cw);
                              ^~   ~~
vi.c:1112:2: note: 'snprintf' output between 3 and 258 bytes into a destination of size 256
  snprintf(ex, sizeof(ex), "e %s", cw);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aligrudi commented 1 year ago

Stefan @.***> wrote:


cc -c -Wall -O2 vi.c
vi.c: In function 'vi_motion':
vi.c:546:32: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 254 [-Wformat-truncation=]
   snprintf(kw, sizeof(kw), "\\<%s\\>", cw);
                                ^~      ~~
vi.c:546:3: note: 'snprintf' output between 5 and 260 bytes into a destination of size 256
   snprintf(kw, sizeof(kw), "\\<%s\\>", cw);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vi.c: In function 'vc_gotopath':
vi.c:1112:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 254 [-Wformat-truncation=]
  snprintf(ex, sizeof(ex), "e %s", cw);
                              ^~   ~~
vi.c:1112:2: note: 'snprintf' output between 3 and 258 bytes into a destination of size 256
  snprintf(ex, sizeof(ex), "e %s", cw);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks, fixed.

Ali
polluks commented 1 year ago

A new one


cc -c -Wall -O2 vi.c
vi.c:1315:10: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                                        if (!vi_curword(xb, cw, sizeof(cw), xrow, xoff, "-/.") != 0) {
                                            ^                                                  ~~
vi.c:1315:10: note: add parentheses after the '!' to evaluate the comparison first
                                        if (!vi_curword(xb, cw, sizeof(cw), xrow, xoff, "-/.") != 0) {
                                            ^
                                             (                                                     )
vi.c:1315:10: note: add parentheses around left hand side expression to silence this warning
                                        if (!vi_curword(xb, cw, sizeof(cw), xrow, xoff, "-/.") != 0) {
                                            ^
                                            (                                                 )
1 warning generated.
aligrudi commented 1 year ago

Stefan @.***> wrote:

A new one


cc -c -Wall -O2 vi.c
vi.c:1315:10: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                                        if (!vi_curword(xb, cw, sizeof(cw), xrow, xoff, "-/.") != 0) {
                                            ^                                                  ~~

Fixed. Thanks.

Ali