smcameron / open-simplex-noise-in-c

Port of Kurt Spencer's java implementation of open simplex noise to C -- Note: This is NOT Ken Perlin's Simplex noise algorithm.
The Unlicense
139 stars 19 forks source link

Spurious assignments #4

Closed stolk closed 2 years ago

stolk commented 10 years ago

There are quite a few assignments in the code that appear to have no use.

/Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:678:5: warning: Value stored to 'aScore' is never read aScore = score; ^ ~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:682:5: warning: Value stored to 'bScore' is never read bScore = score; ^ ~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:689:5: warning: Value stored to 'aScore' is never read aScore = score; ^ ~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:693:5: warning: Value stored to 'bScore' is never read bScore = score; ^ ~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:1429:4: warning: Value stored to 'bScore' is never read bScore = p4; ^ ~~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:1433:4: warning: Value stored to 'aScore' is never read aScore = p4; ^ ~~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:1858:4: warning: Value stored to 'bScore' is never read bScore = p4; ^ ~~ /Users/bram/apps/Proto/Dig/Dig/open-simplex-noise.c:1862:4: warning: Value stored to 'aScore' is never read aScore = p4; ^ ~~ 8 warnings generated.

smcameron commented 10 years ago

What compiler or compiler options are you using to get those warnings? clang?

Probably best to inform KdotJPG ( https://github.com/KdotJPG ) if we can figure out how, since he's the author of the java code from which this code is derived. https://gist.github.com/KdotJPG/b1270127455a94ac5d19

-- steve

stolk commented 10 years ago

clang analyzer (in xcode.)

I was not sure if it was a transcription error from java to C, or an issue in the original.

bram

On Mon, Nov 3, 2014 at 8:18 PM, smcameron notifications@github.com wrote:

What compiler or compiler options are you using to get those warnings? clang?

Probably best to inform KdotJPG ( https://github.com/KdotJPG ) if we can figure out how, since he's the author of the java code from which this code is derived. https://gist.github.com/KdotJPG/b1270127455a94ac5d19

-- steve

— Reply to this email directly or view it on GitHub https://github.com/smcameron/open-simplex-noise-in-c/issues/4#issuecomment-61591589 .

“Programming today is a race between software engineers striving to build bigger and better idiot- proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” (R Cook).

smcameron commented 10 years ago

Possibly transcription error, but the transcription was almost amazingly straightforward, so if a problem exists here, it probably also exists in the original.

crabctrl commented 2 years ago

Invoking the Clang static analyzer with clang --analyze open-simplex-noise.c produces similar output, albeit with different line numbers, likely due to changes to the code since 2014.

On lines 700, 704, 711, and 715, aScore or bScore are set, but neither is used again in the remainder of open_simplex_noise3, so the assignment is indeed spurious.

The static analyzer also complains about lines 1467, 1471, 1891, and 1895, however that function is significantly longer and I've not had time to look at it it yet.

smcameron commented 2 years ago

The above commits should 1) enable running the clang static analyzer via "make scan-build", and 2) remove the dead stores that it detected.