hercules-390 / hyperion

Hercules 390
Other
251 stars 70 forks source link

Fix inverted calloc parameters #303

Closed rbanffy closed 4 months ago

rbanffy commented 4 months ago

Very minor commit - noticed it when the compiler spat out a warning.

wrljet commented 4 months ago

Curious which compiler and what warning?

rbanffy commented 4 months ago

GCC 14 popped up a warning for the instance with the "1" as the second argument. The rest I looked for manually. It was during multiple runs at building a Docker image.

On Tue, May 7, 2024 at 9:09 PM Bill Lewis @.***> wrote:

Curious which compiler and what warning?

— Reply to this email directly, view it on GitHub https://github.com/hercules-390/hyperion/pull/303#issuecomment-2099216307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABNDCUJU3LWYZOICSE46ZDZBEYIPAVCNFSM6AAAAABHLQFDJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGIYTMMZQG4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Ricardo Bánffy http://about.me/rbanffy

rbanffy commented 4 months ago

Curious which compiler and what warning?

This is the warning. I noticed a couple other instances (not of the warning, but on the mistake). I find it lucky (and part responsible for these issues) that this function is commutative.

shared.c: In function 'serverConnect':
shared.c:2458:43: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 2458 |     if (!(dev->shrd[ix] = calloc( sizeof( SHRD ), 1 )))
      |                                           ^~~~
shared.c:2458:43: note: earlier argument should specify number of elements, later size of each element
  CCLD     libhercd.la