ref: 12a66c0a2143fa8851be2c4473598c48b184890a
parent: 86feee5b7b00b36758bb81ca3614daf61b99fc3c
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Dec 23 11:28:15 EST 2016
Fix printf format warnings. We can't print function pointer addresses at all, since converting a function pointer to a void* is forbidden with ANSI C, so we only print the function name.
--- a/jsdump.c
+++ b/jsdump.c
@@ -810,26 +810,26 @@
break;
}
switch (v.u.object->type) {
- case JS_COBJECT: printf("[Object %p]", v.u.object); break;
- case JS_CARRAY: printf("[Array %p]", v.u.object); break;
+ case JS_COBJECT: printf("[Object %p]", (void*)v.u.object); break;
+ case JS_CARRAY: printf("[Array %p]", (void*)v.u.object); break;
case JS_CFUNCTION:
printf("[Function %p, %s, %s:%d]",
- v.u.object,
+ (void*)v.u.object,
v.u.object->u.f.function->name,
v.u.object->u.f.function->filename,
v.u.object->u.f.function->line);
break;
case JS_CSCRIPT: printf("[Script %s]", v.u.object->u.f.function->filename); break;
- case JS_CCFUNCTION: printf("[CFunction %p]", v.u.object->u.c.function); break;
+ case JS_CCFUNCTION: printf("[CFunction %s]", v.u.object->u.c.name); break;
case JS_CBOOLEAN: printf("[Boolean %d]", v.u.object->u.boolean); break;
case JS_CNUMBER: printf("[Number %g]", v.u.object->u.number); break;
case JS_CSTRING: printf("[String'%s']", v.u.object->u.s.string); break;
case JS_CERROR: printf("[Error %s]", v.u.object->u.s.string); break;
- case JS_CITERATOR: printf("[Iterator %p]", v.u.object); break;
+ case JS_CITERATOR: printf("[Iterator %p]", (void*)v.u.object); break;
case JS_CUSERDATA:
printf("[Userdata %s %p]", v.u.object->u.user.tag, v.u.object->u.user.data);
break;
- default: printf("[Object %p]", v.u.object); break;
+ default: printf("[Object %p]", (void*)v.u.object); break;
}
break;
}
--- a/jsstring.c
+++ b/jsstring.c
@@ -159,7 +159,7 @@
{
const char *haystack = checkstring(J, 0);
const char *needle = js_tostring(J, 1);
- int pos = js_isdefined(J, 2) ? js_tointeger(J, 2) : strlen(haystack);
+ int pos = js_isdefined(J, 2) ? js_tointeger(J, 2) : (int)strlen(haystack);
int len = strlen(needle);
int k = 0, last = -1;
Rune rune;