Skip to content

coordlist_ops: adjust memcpy call for macro#226

Merged
bk138 merged 1 commit intobk138:masterfrom
iamleot:memcpy-macro-ssp
May 4, 2025
Merged

coordlist_ops: adjust memcpy call for macro#226
bk138 merged 1 commit intobk138:masterfrom
iamleot:memcpy-macro-ssp

Conversation

@iamleot
Copy link
Copy Markdown
Contributor

@iamleot iamleot commented May 4, 2025

In some SSP implementations - like NetBSD ssp(3) - memcpy(3) can be a macro and the build will fail because the macro will see 8 arguments instead of 3.

Actual build error, included for convenience:

[ 69%] Building C object CMakeFiles/gromit-mpx.dir/src/coordlist_ops.c.o
.../pkgsrc/wip/gromit-mpx/work/gromit-mpx-1.7.0/src/coordlist_ops.c: In function 'unity2D':
.../pkgsrc/wip/gromit-mpx/work/gromit-mpx-1.7.0/src/coordlist_ops.c:273:78: error: macro "memcpy" passed 8 arguments, but takes just 3
  273 |     memcpy(m->m, (gfloat[6]){1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, sizeof(gfloat[6]));
      |                                                                              ^
In file included from /usr/include/string.h:128,
                 from .../pkgsrc/wip/gromit-mpx/work/gromit-mpx-1.7.0/src/coordlist_ops.c:26:
/usr/include/ssp/string.h:95: note: macro "memcpy" defined here
   95 | #define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
      |
.../pkgsrc/wip/gromit-mpx/work/gromit-mpx-1.7.0/src/coordlist_ops.c:273:5: warning: statement with no effect [-Wunused-value]
  273 |     memcpy(m->m, (gfloat[6]){1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, sizeof(gfloat[6]));
      |     ^~~~~~

I have noticed it while packaging gromit-mpx in pkgsrc on NetBSD.

In some SSP implementations - like NetBSD ssp(3) - memcpy(3) can be a
macro and the build will fail because the macro will see 8 arguments
instead of 3.
@iamleot iamleot marked this pull request as ready for review May 4, 2025 20:12
@bk138 bk138 merged commit 6f9c7a0 into bk138:master May 4, 2025
1 check passed
@bk138
Copy link
Copy Markdown
Owner

bk138 commented May 4, 2025

Well-crafted PR, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants