pete-gordon / hivelytracker

Chip music tracker based on AHX
http://www.hivelytracker.co.uk
BSD 3-Clause "New" or "Revised" License
117 stars 15 forks source link

Warnings from clang scan-build #59

Open mvtiaine opened 1 year ago

mvtiaine commented 1 year ago

Hi Peter,

I recently added HivelyTracker support to my Audacious UADE plugin https://github.com/mvtiaine/audacious-uade

Running the build with clang scan-build I noticed there's two warnings from HivelyTracker code (using the Replay_Windows code, but seems to apply for all replay versions):

1)

https://github.com/pete-gordon/hivelytracker/blob/master/Replayer_Windows/hvl_tables.c#L506

3rdparty/hvl/hvl_tables.c:510:24: warning: The result of the left shift is undefined because the left operand is negative [core.UndefinedBinaryOperatorResult]
  510 |                         mid  = *mid_table++ << 8;
      |                                ~~~~~~~~~~~~ ^

2)

https://github.com/pete-gordon/hivelytracker/blob/master/Replayer_Windows/hvl_replay.c#L1360

3rdparty/hvl/hvl_replay.c:1361:31: warning: Access to field 'ins_SquareSpeed' results in a dereference of a null pointer (loaded from field 'vc_Instrument') [core.NullDereference]
 1361 |       voice->vc_SquareWait  = voice->vc_Instrument->ins_SquareSpeed;
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.