-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix compilation errors when EXIF_DEBUG is defined. #5838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
On Ubuntu 18.4 with GCC 7.5, defining EXIF_DEBUG causes the following errors and warnings in ext/exif/exif.f. This patch fixes them. It leaves EXIF_DEBUG undefined, so if you want to verify, you will have to define it. $ make /bin/bash /home/nat/projects/php-exif/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/exif/ -I/home/nat/projects/php-exif/php-src/ext/exif/ -DPHP_ATOM_INC -I/home/nat/projects/php-exif/php-src/include -I/home/nat/projects/php-exif/php-src/main -I/home/nat/projects/php-exif/php-src -I/home/nat/projects/php-exif/php-src/ext/date/lib -I/usr/include/libxml2 -I/home/nat/projects/php-exif/php-src/TSRM -I/home/nat/projects/php-exif/php-src/Zend -I/usr/include -g -fvisibility=hidden -O0 -Wall -Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare -Wno-clobbered -DZEND_SIGNALS -c /home/nat/projects/php-exif/php-src/ext/exif/exif.c -o ext/exif/exif.lo /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_char_dump’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1383:16: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign] p += slprintf(buf+p, sizeof(buf)-p, "\nDump Len: %08X (%d)", len, len); ^~~ In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0, from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22: /home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4); ^~~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1387:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign] p += slprintf(buf+p, sizeof(buf)-p, "\n%08X: ", i+offset); ^~~ In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0, from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22: /home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4); ^~~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1391:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign] p += slprintf(buf+p, sizeof(buf)-p, "%02X ", c); ^~~ In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0, from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22: /home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4); ^~~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1395:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign] p += slprintf(buf+p, sizeof(buf)-p, " "); ^~~ In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0, from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22: /home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4); ^~~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1398:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign] p += slprintf(buf+p, sizeof(buf)-p, " %s", tmp); ^~~ In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0, from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22: /home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’ PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4); ^~~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_error_docref’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:2006:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t {aka long unsigned int}’ [-Wformat=] spprintf(&buf, 0, "%s(%d): %s", _file, _line, format); ~^ %ld /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘add_assoc_image_info’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:2448:7: warning: unused variable ‘info_tag’ [-Wunused-variable] int info_tag = info_data->tag; /* conversion */ ^~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_thumbnail_build’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:2850:20: warning: unused variable ‘tagname’ [-Wunused-variable] char tagname[64]; ^~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_process_IFD_in_MAKERNOTE’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:132: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement)); ^ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:152: error: ‘offset_base’ undeclared (first use in this function); did you mean ‘offsetof’? exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement)); ^~~~~~~~~~~ offsetof /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:152: note: each undeclared identifier is reported only once for each function it appears in /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:256: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] ocess %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement)); ^ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:234: warning: pointer targets in passing argument 1 of ‘exif_char_dump’ differ in signedness [-Wpointer-sign] ageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement)); ^~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c:1377:23: note: expected ‘unsigned char *’ but argument is of type ‘char *’ static unsigned char* exif_char_dump(unsigned char * addr, int len, int offset) ^~~~~~~~~~~~~~ /home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_process_IFD_in_JPEG’: /home/nat/projects/php-exif/php-src/ext/exif/exif.c:3564:122: error: ‘IFDlength’ undeclared (first use in this function) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectionname(section_index), IFDlength, IFDlength); ^~~~~~~~~ Makefile:740: recipe for target 'ext/exif/exif.lo' failed make: *** [ext/exif/exif.lo] Error 1
The failing checks are not due to the changes, since they're all under EXIF_DEBUG, which is undefined. Make test was failing for me, too, on a clean branch. Not sure how the community handles this. |
@@ -3152,14 +3156,13 @@ static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * val | |||
|
|||
if (value_len < 2 || maker_note->offset >= value_len - 1) { | |||
/* Do not go past the value end */ | |||
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X offset 0x%04X", value_len, maker_note->offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this removal causes two tests to fail (regardless of platform).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've restored this in 2d98f0c.
On Ubuntu 18.4 with GCC 7.5, defining EXIF_DEBUG causes the following errors and warnings
in ext/exif/exif.f. This patch fixes them. It leaves EXIF_DEBUG undefined, so if you want
to verify, you will have to define it.
$ make
/bin/bash /home/nat/projects/php-exif/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/exif/ -I/home/nat/projects/php-exif/php-src/ext/exif/ -DPHP_ATOM_INC -I/home/nat/projects/php-exif/php-src/include -I/home/nat/projects/php-exif/php-src/main -I/home/nat/projects/php-exif/php-src -I/home/nat/projects/php-exif/php-src/ext/date/lib -I/usr/include/libxml2 -I/home/nat/projects/php-exif/php-src/TSRM -I/home/nat/projects/php-exif/php-src/Zend -I/usr/include -g -fvisibility=hidden -O0 -Wall -Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare -Wno-clobbered -DZEND_SIGNALS -c /home/nat/projects/php-exif/php-src/ext/exif/exif.c -o ext/exif/exif.lo
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_char_dump’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1383:16: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign]
p += slprintf(buf+p, sizeof(buf)-p, "\nDump Len: %08X (%d)", len, len);
^~~
In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0,
from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22:
/home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
^~~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1387:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign]
p += slprintf(buf+p, sizeof(buf)-p, "\n%08X: ", i+offset);
^~~
In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0,
from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22:
/home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
^~~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1391:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign]
p += slprintf(buf+p, sizeof(buf)-p, "%02X ", c);
^~~
In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0,
from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22:
/home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
^~~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1395:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign]
p += slprintf(buf+p, sizeof(buf)-p, " ");
^~~
In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0,
from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22:
/home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char *format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
^~~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1398:19: warning: pointer targets in passing argument 1 of ‘ap_php_slprintf’ differ in signedness [-Wpointer-sign]
p += slprintf(buf+p, sizeof(buf)-p, " %s", tmp);
^~~
In file included from /home/nat/projects/php-exif/php-src/main/php.h:269:0,
from /home/nat/projects/php-exif/php-src/ext/exif/exif.c:22:
/home/nat/projects/php-exif/php-src/main/snprintf.h:77:12: note: expected ‘char *’ but argument is of type ‘unsigned char *’
PHPAPI int ap_php_slprintf(char *buf, size_t len, const char format,...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
^~~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_error_docref’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:2006:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
spprintf(&buf, 0, "%s(%d): %s", _file, _line, format);
~^
%ld
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘add_assoc_image_info’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:2448:7: warning: unused variable ‘info_tag’ [-Wunused-variable]
int info_tag = info_data->tag; / conversion */
^~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_thumbnail_build’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:2850:20: warning: unused variable ‘tagname’ [-Wunused-variable]
char tagname[64];
^~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_process_IFD_in_MAKERNOTE’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:132: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement));
^
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:152: error: ‘offset_base’ undeclared (first use in this function); did you mean ‘offsetof’?
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement));
^~~~~~~~~~~
offsetof
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:152: note: each undeclared identifier is reported only once for each function it appears in
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:256: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
ocess %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement));
^
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3162:234: warning: pointer targets in passing argument 1 of ‘exif_char_dump’ differ in signedness [-Wpointer-sign]
ageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (int)dir_start-(int)offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (int)dir_start-(int)offset_base+maker_note->offset+displacement));
^~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:1377:23: note: expected ‘unsigned char *’ but argument is of type ‘char ’
static unsigned char exif_char_dump(unsigned char * addr, int len, int offset)
^~~~~~~~~~~~~~
/home/nat/projects/php-exif/php-src/ext/exif/exif.c: In function ‘exif_process_IFD_in_JPEG’:
/home/nat/projects/php-exif/php-src/ext/exif/exif.c:3564:122: error: ‘IFDlength’ undeclared (first use in this function)
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s (x%04X(=%d))", exif_get_sectionname(section_index), IFDlength, IFDlength);
^~~~~~~~~
Makefile:740: recipe for target 'ext/exif/exif.lo' failed
make: *** [ext/exif/exif.lo] Error 1