Skip to content

Commit 192fad7

Browse files
committed
ext/exif: Fix some [-Wsign-compare] warnings
1 parent b8aa227 commit 192fad7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

ext/exif/exif.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ ZEND_GET_MODULE(exif)
220220
* is read or until there is no more data available to read. */
221221
static ssize_t exif_read_from_stream_file_looped(php_stream *stream, char *buf, size_t count)
222222
{
223-
ssize_t total_read = 0;
223+
size_t total_read = 0;
224224
while (total_read < count) {
225225
ssize_t ret = php_stream_read(stream, buf + total_read, count - total_read);
226226
if (ret == -1) {
@@ -2185,17 +2185,13 @@ static image_info_data *exif_alloc_image_info_data(image_info_list *info_list) {
21852185
/* {{{ exif_iif_add_value
21862186
Add a value to image_info
21872187
*/
2188-
static void exif_iif_add_value(image_info_type *image_info, int section_index, char *name, int tag, int format, int length, void* value, size_t value_len, int motorola_intel)
2188+
static void exif_iif_add_value(image_info_type *image_info, int section_index, char *name, int tag, int format, size_t length, void* value, size_t value_len, int motorola_intel)
21892189
{
21902190
size_t idex;
21912191
void *vptr, *vptr_end;
21922192
image_info_value *info_value;
21932193
image_info_data *info_data;
21942194

2195-
if (length < 0) {
2196-
return;
2197-
}
2198-
21992195
info_data = exif_alloc_image_info_data(&image_info->info_list[section_index]);
22002196
memset(info_data, 0, sizeof(image_info_data));
22012197
info_data->tag = tag;
@@ -2211,7 +2207,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
22112207
value = NULL;
22122208
}
22132209
if (value) {
2214-
length = (int)zend_strnlen(value, length);
2210+
length = zend_strnlen(value, length);
22152211
info_value->s = estrndup(value, length);
22162212
info_data->length = length;
22172213
} else {
@@ -2242,7 +2238,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
22422238
}
22432239
if (value) {
22442240
if (tag == TAG_MAKER_NOTE) {
2245-
length = (int) zend_strnlen(value, length);
2241+
length = zend_strnlen(value, length);
22462242
}
22472243

22482244
/* do not recompute length here */
@@ -2264,14 +2260,14 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
22642260
case TAG_FMT_DOUBLE:
22652261
if (length==0) {
22662262
break;
2267-
} else
2263+
}
22682264
if (length>1) {
22692265
info_value->list = safe_emalloc(length, sizeof(image_info_value), 0);
22702266
} else {
22712267
info_value = &info_data->value;
22722268
}
22732269
vptr_end = (char *) value + value_len;
2274-
for (idex=0,vptr=value; idex<(size_t)length; idex++,vptr=(char *) vptr + php_tiff_bytes_per_format[format]) {
2270+
for (idex=0,vptr=value; idex<length; idex++,vptr=(char *) vptr + php_tiff_bytes_per_format[format]) {
22752271
if ((char *) vptr_end - (char *) vptr < php_tiff_bytes_per_format[format]) {
22762272
exif_error_docref("exif_iif_add_value" EXIFERR_CC, image_info, E_WARNING, "Value too short");
22772273
break;
@@ -2330,7 +2326,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
23302326
*/
23312327
static void exif_iif_add_tag(image_info_type *image_info, int section_index, char *name, int tag, int format, size_t length, void* value, size_t value_len)
23322328
{
2333-
exif_iif_add_value(image_info, section_index, name, tag, format, (int)length, value, value_len, image_info->motorola_intel);
2329+
exif_iif_add_value(image_info, section_index, name, tag, format, length, value, value_len, image_info->motorola_intel);
23342330
}
23352331
/* }}} */
23362332

0 commit comments

Comments
 (0)