Skip to content

Fix -Wformat compiler warnings in zif_uv_timer_start - #124

Open
andypost wants to merge 1 commit into
amphp:0.3.xfrom
andypost:fix-warnings
Open

andypost wants to merge 1 commit into
amphp:0.3.xfrom
andypost:fix-warnings

Conversation

@andypost

Copy link
Copy Markdown

Use ZEND_LONG_FMT instead of %lld for zend_long variables (timeout and repeat) to ensure proper 32-bit and 64-bit cross-platform compatibility.

Using it to upgrade the extension in Alpinelinux

Generating files
configure: creating build directories
configure: creating Makefile
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
/bin/sh /mnt/testing/php84-pecl-uv/src/uv-0.3.1/libtool --tag=CC --mode=compile cc -I. -I/mnt/testing/php84-pecl-uv/src/uv-0.3.1 -I/usr/include/php84 -I/usr/include/php84/main -I/usr/include/php84/TSRM -I/usr/include/php84/Zend -I/usr/include/php84/ext -I/usr/include/php84/ext/date/lib  -DHAVE_CONFIG_H  -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /mnt/testing/php84-pecl-uv/src/uv-0.3.1/php_uv.c -o php_uv.lo  -MMD -MF php_uv.dep -MT php_uv.lo
/bin/sh /mnt/testing/php84-pecl-uv/src/uv-0.3.1/libtool --tag=CC --mode=compile cc -I. -I/mnt/testing/php84-pecl-uv/src/uv-0.3.1 -I/usr/include/php84 -I/usr/include/php84/main -I/usr/include/php84/TSRM -I/usr/include/php84/Zend -I/usr/include/php84/ext -I/usr/include/php84/ext/date/lib  -DHAVE_CONFIG_H  -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /mnt/testing/php84-pecl-uv/src/uv-0.3.1/uv.c -o uv.lo  -MMD -MF uv.dep -MT uv.lo
mkdir .libs
mkdir .libs
mkdir: can't create directory '.libs': File exists
 cc -I. -I/mnt/testing/php84-pecl-uv/src/uv-0.3.1 -I/usr/include/php84 -I/usr/include/php84/main -I/usr/include/php84/TSRM -I/usr/include/php84/Zend -I/usr/include/php84/ext -I/usr/include/php84/ext/date/lib -DHAVE_CONFIG_H -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /mnt/testing/php84-pecl-uv/src/uv-0.3.1/uv.c -MMD -MF uv.dep -MT uv.lo  -fPIC -DPIC -o .libs/uv.o
 cc -I. -I/mnt/testing/php84-pecl-uv/src/uv-0.3.1 -I/usr/include/php84 -I/usr/include/php84/main -I/usr/include/php84/TSRM -I/usr/include/php84/Zend -I/usr/include/php84/ext -I/usr/include/php84/ext/date/lib -DHAVE_CONFIG_H -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /mnt/testing/php84-pecl-uv/src/uv-0.3.1/php_uv.c -MMD -MF php_uv.dep -MT php_uv.lo  -fPIC -DPIC -o .libs/php_uv.o
/mnt/testing/php84-pecl-uv/src/uv-0.3.1/php_uv.c: In function 'zif_uv_timer_start':
/mnt/testing/php84-pecl-uv/src/uv-0.3.1/php_uv.c:4130:101: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'zend_long' {aka 'long int'} [-Wformat=]
 4130 |                 php_error_docref(NULL, E_WARNING, "timeout value have to be larger than 0. given %lld", timeout);
      |                                                                                                  ~~~^   ~~~~~~~
      |                                                                                                     |   |
      |                                                                                                     |   zend_long {aka long int}
      |                                                                                                     long long int
      |                                                                                                  %ld
/mnt/testing/php84-pecl-uv/src/uv-0.3.1/php_uv.c:4135:100: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'zend_long' {aka 'long int'} [-Wformat=]
 4135 |                 php_error_docref(NULL, E_WARNING, "repeat value have to be larger than 0. given %lld", repeat);
      |                                                                                                 ~~~^   ~~~~~~
      |                                                                                                    |   |
      |                                                                                                    |   zend_long {aka long int}
      |                                                                                                    long long int
      |                                                                                                 %ld
/bin/sh /mnt/testing/php84-pecl-uv/src/uv-0.3.1/libtool --tag=CC --mode=link cc -shared -I/usr/include/php84 -I/usr/include/php84/main -I/usr/include/php84/TSRM -I/usr/include/php84/Zend -I/usr/include/php84/ext -I/usr/include/php84/ext/date/lib  -DHAVE_CONFIG_H  -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -D_GNU_SOURCE  -Wl,--as-needed,-O1,--sort-common -Wl,-z,pack-relative-relocs  -o uv.la -export-dynamic -avoid-version -prefer-pic -module -rpath /mnt/testing/php84-pecl-uv/src/uv-0.3.1/modules  php_uv.lo uv.lo -luv
cc -shared  .libs/php_uv.o .libs/uv.o  -luv  -Wl,--as-needed -Wl,-O1 -Wl,--sort-common -Wl,-z -Wl,pack-relative-relocs -Wl,-soname -Wl,uv.so -o .libs/uv.so
creating uv.la

Use ZEND_LONG_FMT instead of %lld for zend_long variables (timeout and repeat)
to ensure proper 32-bit and 64-bit cross-platform compatibility.
@andypost

Copy link
Copy Markdown
Author

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant