Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use &X[3] instead of X + 3 to fix clang warnings #3151

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

rootkea
Copy link
Contributor

@rootkea rootkea commented Sep 6, 2021

Hello!

On latest master clang version 10.0.0-4ubuntu1 produces following warnings:

parsers/lisp.c:128:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("DEFUN"))
                    ^~~~~~~~~~~~
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:128:7: note: use array indexing to silence this warning
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:133:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("DEFVAR"))
                    ^~~~~~~~~~~~~
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:133:7: note: use array indexing to silence this warning
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:138:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("DEFMACRO"))
                    ^~~~~~~~~~~~~~~
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:138:7: note: use array indexing to silence this warning
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:143:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("DEFCONSTANT"))
                    ^~~~~~~~~~~~~~~~~~
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:143:7: note: use array indexing to silence this warning
parsers/lisp.c:123:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:163:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defun"))
                    ^~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:163:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:168:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defvar"))
                    ^~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:168:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:170:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defun*"))
                         ^~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:170:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:175:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defface"))
                    ^~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:175:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:179:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defconst"))
                    ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:179:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:181:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defmacro"))
                         ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:181:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:183:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defalias"))
                         ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:183:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:185:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defsubst"))
                         ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:185:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:187:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defgroup"))
                         ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:187:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:189:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("deftheme"))
                         ^~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:189:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:194:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defcustom"))
                    ^~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:194:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:196:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defsubst*"))
                         ^~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:196:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:198:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("defmacro*"))
                         ^~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:198:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:203:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-key"))
                    ^~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:203:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:208:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defvar-local"))
                    ^~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:208:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:210:12: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                else if (EQN("define-error"))
                         ^~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:210:12: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:215:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("defvaralias"))
                    ^~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:215:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:220:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-inline"))
                    ^~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:220:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:225:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-minor-mode"))
                    ^~~~~~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:225:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:230:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-derived-mode"))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:230:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:235:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-global-minor-mode"))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:235:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:240:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-globalized-minor-mode"))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:240:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^
parsers/lisp.c:245:7: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
                if (EQN("define-obsolete-function-alias"))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                ~~^~~
parsers/lisp.c:245:7: note: use array indexing to silence this warning
parsers/lisp.c:158:51: note: expanded from macro 'EQN'
#define EQN(X) strncmp(vStringValue (hint) + 4, X + 3, n) == 0
                                                  ^

This PR fixes these warnings.

Thanks!

@rootkea rootkea changed the title Use &X[3] instead of X + 3 to fix clang warning Use &X[3] instead of X + 3 to fix clang warnings Sep 6, 2021
@codecov
Copy link

codecov bot commented Sep 6, 2021

Codecov Report

Merging #3151 (aec0c38) into master (ca81123) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3151   +/-   ##
=======================================
  Coverage   84.89%   84.89%           
=======================================
  Files         200      200           
  Lines       47827    47827           
=======================================
  Hits        40604    40604           
  Misses       7223     7223           
Impacted Files Coverage Δ
parsers/lisp.c 89.26% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca81123...aec0c38. Read the comment docs.

@masatake masatake merged commit 9a7b9bc into universal-ctags:master Sep 6, 2021
@masatake
Copy link
Member

masatake commented Sep 6, 2021

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants