Thrift: Better handling of strerror_r.
Summary:
Someone thought it would be a good idea to have two different signatures
for strerror_r, with subtly different semantics (strlcpy = smart).
We now work properly with either of them.
Also fixed a test to work on 32-bit, you sloppy <expletive>s.
Reviewed By: mcslee
Test Plan:
Rebuild thrift.
Force one of these errors to be thrown.
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665215 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index e1110b4..c2efb1a 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -8,6 +8,9 @@
#include <boost/shared_ptr.hpp>
#include "ThriftTest.h"
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
using namespace boost;
using namespace std;
using namespace facebook::thrift;
@@ -137,7 +140,7 @@
*/
printf("testI64(-34359738368)");
int64_t i64 = testClient.testI64(-34359738368LL);
- printf(" = %ld\n", i64);
+ printf(" = %"PRId64"\n", i64);
/**
* DOUBLE TEST
@@ -157,7 +160,7 @@
out.i64_thing = -5;
Xtruct in;
testClient.testStruct(in, out);
- printf(" = {\"%s\", %d, %d, %ld}\n",
+ printf(" = {\"%s\", %d, %d, %"PRId64"}\n",
in.string_thing.c_str(),
(int)in.byte_thing,
in.i32_thing,
@@ -174,7 +177,7 @@
Xtruct2 in2;
testClient.testNest(in2, out2);
in = in2.struct_thing;
- printf(" = {%d, {\"%s\", %d, %d, %ld}, %d}\n",
+ printf(" = {%d, {\"%s\", %d, %d, %"PRId64"}, %d}\n",
in2.byte_thing,
in.string_thing.c_str(),
(int)in.byte_thing,
@@ -309,7 +312,7 @@
*/
printf("testTypedef(309858235082523)");
UserId uid = testClient.testTypedef(309858235082523LL);
- printf(" = %ld\n", uid);
+ printf(" = %"PRId64"\n", uid);
/**
* NESTED MAP TEST
@@ -346,7 +349,7 @@
printf(" = {");
map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
- printf("%ld => {", i_iter->first);
+ printf("%"PRId64" => {", i_iter->first);
map<Numberz,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
@@ -356,7 +359,7 @@
map<Numberz, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
- printf("%d => %ld, ", um->first, um->second);
+ printf("%d => %"PRId64", ", um->first, um->second);
}
printf("}, ");
@@ -364,7 +367,7 @@
vector<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
- printf("{\"%s\", %d, %d, %ld}, ",
+ printf("{\"%s\", %d, %d, %"PRId64"}, ",
x->string_thing.c_str(),
(int)x->byte_thing,
x->i32_thing,
@@ -430,7 +433,7 @@
uint64_t stop = now();
uint64_t tot = stop-start;
- printf("Total time: %lu us\n", stop-start);
+ printf("Total time: %"PRIu64" us\n", stop-start);
time_tot += tot;
if (time_min == 0 || tot < time_min) {
@@ -448,9 +451,9 @@
uint64_t time_avg = time_tot / numTests;
- printf("Min time: %lu us\n", time_min);
- printf("Max time: %lu us\n", time_max);
- printf("Avg time: %lu us\n", time_avg);
+ printf("Min time: %"PRIu64" us\n", time_min);
+ printf("Max time: %"PRIu64" us\n", time_max);
+ printf("Avg time: %"PRIu64" us\n", time_avg);
return 0;
}
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index c8ecf15..3afc955 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -13,6 +13,9 @@
#include <stdexcept>
#include <sstream>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
using namespace std;
using namespace boost;
@@ -48,7 +51,7 @@
}
int64_t testI64(const int64_t thing) {
- printf("testI64(%ld)\n", thing);
+ printf("testI64(%"PRId64")\n", thing);
return thing;
}
@@ -58,13 +61,13 @@
}
void testStruct(Xtruct& out, const Xtruct &thing) {
- printf("testStruct({\"%s\", %d, %d, %ld})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
+ printf("testStruct({\"%s\", %d, %d, %"PRId64"})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
out = thing;
}
void testNest(Xtruct2& out, const Xtruct2& nest) {
const Xtruct &thing = nest.struct_thing;
- printf("testNest({%d, {\"%s\", %d, %d, %ld}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
+ printf("testNest({%d, {\"%s\", %d, %d, %"PRId64"}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
out = nest;
}
@@ -122,7 +125,7 @@
}
UserId testTypedef(const UserId thing) {
- printf("testTypedef(%ld)\n", thing);
+ printf("testTypedef(%"PRId64")\n", thing);
return thing;
}
@@ -179,7 +182,7 @@
printf(" = {");
map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
- printf("%ld => {", i_iter->first);
+ printf("%"PRId64" => {", i_iter->first);
map<Numberz,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
@@ -189,7 +192,7 @@
map<Numberz, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
- printf("%d => %ld, ", um->first, um->second);
+ printf("%d => %"PRId64", ", um->first, um->second);
}
printf("}, ");
@@ -197,7 +200,7 @@
vector<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
- printf("{\"%s\", %d, %d, %ld}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
+ printf("{\"%s\", %d, %d, %"PRId64"}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
}
printf("}");