a question for SARG

General FreeBASIC programming questions.
Post Reply
srvaldez
Posts: 3390
Joined: Sep 25, 2005 21:54

a question for SARG

Post by srvaldez »

hello SARG :)
when building FB with gcc-13+ you get warnings like Warning: found `movsd'; assuming `movsl' was meant
I think that the culprit are the FB_MEMCPY functions defined in FB.h
how would you change those functions in order to get rid of those warnings?
SARG
Posts: 1785
Joined: May 27, 2005 7:15
Location: FRANCE

Re: a question for SARG

Post by SARG »

Hi srvaldez
Just change movsd by movsl.
It has been done for gfxlib2 (august 2023).
Check in all files if no other cases.
srvaldez
Posts: 3390
Joined: Sep 25, 2005 21:54

Re: a question for SARG

Post by srvaldez »

thank you SARG :D
I was not sure that movsd and movsl were equivalent, google didn't help
srvaldez
Posts: 3390
Joined: Sep 25, 2005 21:54

Re: a question for SARG

Post by srvaldez »

@SARG
2 more warnings that need to be fixed

Code: Select all

src/gfxlib2/gfx_bsave.c: In function 'save_bmp':
src/gfxlib2/gfx_bsave.c:138:64: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  138 |                         paltmp = (unsigned int *)calloc(sizeof(unsigned int), 256);
      |                                                                ^~~~~~~~


src/gfxlib2/win32/gfx_driver_d2d.c: In function 'D2DEnumOutputModes':
src/gfxlib2/win32/gfx_driver_d2d.c:829:66: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  829 |                         DXGI_MODE_DESC* pModeList = calloc(sizeof(*pModeList), numOutputModes);
      |                                                                  ^
      
SARG
Posts: 1785
Joined: May 27, 2005 7:15
Location: FRANCE

Re: a question for SARG

Post by SARG »

Replace by something like that : calloc (sizeof (a) + 0, b)
We will not break old code.

What I found :
-Wcalloc-transposed-args
Warn about calls to allocation functions decorated with attribute alloc_size with two arguments, which use sizeof operator as the earlier size argument and don’t use it as the later size argument. This is a coding style warning. The first argument to calloc is documented to be number of elements in array, while the second argument is size of each element, so calloc (n, sizeof (int)) is preferred over calloc (sizeof (int), n). If sizeof in the earlier argument and not the latter is intentional, the warning can be suppressed by using calloc (sizeof (struct S) + 0, n) or calloc (1 * sizeof (struct S), 4) or using sizeof in the later argument as well.
srvaldez
Posts: 3390
Joined: Sep 25, 2005 21:54

Re: a question for SARG

Post by srvaldez »

that warning doesn't make sense to me, I don't think it's worth the trouble to silence it
thanks SARG for looking into it :)
SARG
Posts: 1785
Joined: May 27, 2005 7:15
Location: FRANCE

Re: a question for SARG

Post by SARG »

Could you verify that inverting the arguments no warning.
srvaldez
Posts: 3390
Joined: Sep 25, 2005 21:54

Re: a question for SARG

Post by srvaldez »

SARG
yes!, that silenced the warnings
now it builds without a single warning 👍😁
Post Reply