zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.64k stars 778 forks source link

Fix variable scope warnings #190

Open ercanersoy opened 4 years ago

ercanersoy commented 4 years ago

Fixed variable scope warnings on jsmn.h, test/testc.c and test/testutil.h files.

These warnings have been founded by using Cppcheck 1.86.

pt300 commented 4 years ago

Breaks C89 compatibility.

pt300 commented 4 years ago

Some of those changes might make sense but I don't really see them as necessary.

ercanersoy commented 4 years ago

Variable scope warnings can reduce optimizations.

pt300 commented 4 years ago

I don't see the point of those optimizations in the tests and doubt that the single redeclaration will matter on platforms targeted by JSMN.

ercanersoy commented 4 years ago

Cppcheck results of jsmn.h on your repository:

jsmn.h:271:7: warning: The scope of the variable 'i' can be reduced. [variableScope]

I have used Cppcheck 1.86. I have used this command line:

cppcheck --language=c --std=c89 --enable=all --template=gcc "jsmn.h"

Reference:

https://stackoverflow.com/questions/23604699/cppcheck-the-scope-of-the-variable-can-be-reduced-and-loop