summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-11-30 15:01:59 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-11-30 15:01:59 +0000
commite66675a25d39bb5dfebea3041c8f2360bcac290c (patch)
treee5f49c1920e87f67c76d0809a224235c762a25a5 /tests
parenta77ab47c2979d9ce6d03aee2ffe9c7a34250d86e (diff)
Merged 0003-Fixed-format-specifiers.patch by Matt Kern.
Fixes cross-platform issues with the length modifier in printf specifiers, most importantly %d -> %ld. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@1020 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'tests')
-rw-r--r--tests/test_decode1.c2
-rw-r--r--tests/test_decode_callbacks.c14
2 files changed, 8 insertions, 8 deletions
diff --git a/tests/test_decode1.c b/tests/test_decode1.c
index 3f02745..b412ea8 100644
--- a/tests/test_decode1.c
+++ b/tests/test_decode1.c
@@ -23,7 +23,7 @@ bool print_person(pb_istream_t *stream)
/* Now the decoding is done, rest is just to print stuff out. */
printf("name: \"%s\"\n", person.name);
- printf("id: %d\n", person.id);
+ printf("id: %ld\n", (long)person.id);
if (person.has_email)
printf("email: \"%s\"\n", person.email);
diff --git a/tests/test_decode_callbacks.c b/tests/test_decode_callbacks.c
index 6c0072d..aaf4cdc 100644
--- a/tests/test_decode_callbacks.c
+++ b/tests/test_decode_callbacks.c
@@ -30,7 +30,7 @@ bool print_int32(pb_istream_t *stream, const pb_field_t *field, void *arg)
if (!pb_decode_varint(stream, &value))
return false;
- printf((char*)arg, (int32_t)value);
+ printf((char*)arg, (long)value);
return true;
}
@@ -40,7 +40,7 @@ bool print_fixed32(pb_istream_t *stream, const pb_field_t *field, void *arg)
if (!pb_dec_fixed32(stream, NULL, &value))
return false;
- printf((char*)arg, value);
+ printf((char*)arg, (long)value);
return true;
}
@@ -50,7 +50,7 @@ bool print_fixed64(pb_istream_t *stream, const pb_field_t *field, void *arg)
if (!pb_dec_fixed64(stream, NULL, &value))
return false;
- printf((char*)arg, value);
+ printf((char*)arg, (long long)value);
return true;
}
@@ -69,18 +69,18 @@ int main()
testmessage.submsg.stringvalue.funcs.decode = &print_string;
testmessage.submsg.stringvalue.arg = "submsg {\n stringvalue: \"%s\"\n";
testmessage.submsg.int32value.funcs.decode = &print_int32;
- testmessage.submsg.int32value.arg = " int32value: %d\n";
+ testmessage.submsg.int32value.arg = " int32value: %ld\n";
testmessage.submsg.fixed32value.funcs.decode = &print_fixed32;
- testmessage.submsg.fixed32value.arg = " fixed32value: %d\n";
+ testmessage.submsg.fixed32value.arg = " fixed32value: %ld\n";
testmessage.submsg.fixed64value.funcs.decode = &print_fixed64;
testmessage.submsg.fixed64value.arg = " fixed64value: %lld\n}\n";
testmessage.stringvalue.funcs.decode = &print_string;
testmessage.stringvalue.arg = "stringvalue: \"%s\"\n";
testmessage.int32value.funcs.decode = &print_int32;
- testmessage.int32value.arg = "int32value: %d\n";
+ testmessage.int32value.arg = "int32value: %ld\n";
testmessage.fixed32value.funcs.decode = &print_fixed32;
- testmessage.fixed32value.arg = "fixed32value: %d\n";
+ testmessage.fixed32value.arg = "fixed32value: %ld\n";
testmessage.fixed64value.funcs.decode = &print_fixed64;
testmessage.fixed64value.arg = "fixed64value: %lld\n";