Merge branch 'master' into grpc_ruby_add_rubocop_fix_lint_style_issues

pull/82/head
Tim Emiola 10 years ago
commit 582f0d4398
  1. 3
      .gitignore
  2. 3142
      Makefile
  3. 8
      build.json
  4. 22
      include/grpc/grpc.h
  5. 2
      include/grpc/support/slice.h
  6. 33
      src/compiler/cpp_generator.cc
  7. 10
      src/compiler/cpp_generator.h
  8. 23
      src/compiler/cpp_generator_helpers.h
  9. 12
      src/compiler/cpp_plugin.cc
  10. 31
      src/compiler/ruby_generator.cc
  11. 4
      src/compiler/ruby_generator.h
  12. 4
      src/compiler/ruby_generator_helpers-inl.h
  13. 9
      src/compiler/ruby_generator_map-inl.h
  14. 39
      src/compiler/ruby_generator_string-inl.h
  15. 9
      src/compiler/ruby_plugin.cc
  16. 4
      src/core/iomgr/alarm.c
  17. 6
      src/core/iomgr/alarm_internal.h
  18. 10
      src/core/iomgr/iomgr.c
  19. 4
      src/core/iomgr/iomgr.h
  20. 8
      src/core/iomgr/iomgr_internal.h
  21. 4
      src/core/iomgr/iomgr_posix.c
  22. 4
      src/core/iomgr/iomgr_posix.h
  23. 6
      src/core/iomgr/pollset_posix.c
  24. 2
      src/core/iomgr/pollset_posix.h
  25. 4
      src/core/iomgr/socket_utils_common_posix.c
  26. 2
      src/core/iomgr/socket_utils_posix.h
  27. 2
      src/core/iomgr/tcp_server.h
  28. 6
      src/core/iomgr/tcp_server_posix.c
  29. 4
      src/core/security/credentials.c
  30. 12
      src/core/security/secure_endpoint.c
  31. 4
      src/core/security/secure_transport_setup.c
  32. 4
      src/core/security/security_context.c
  33. 4
      src/core/statistics/census_init.c
  34. 6
      src/core/statistics/census_interface.h
  35. 10
      src/core/statistics/census_log.c
  36. 8
      src/core/statistics/census_log.h
  37. 10
      src/core/statistics/census_rpc_stats.c
  38. 6
      src/core/statistics/census_rpc_stats.h
  39. 16
      src/core/statistics/census_tracing.c
  40. 8
      src/core/statistics/census_tracing.h
  41. 4
      src/core/support/cpu.h
  42. 4
      src/core/support/cpu_linux.c
  43. 4
      src/core/support/cpu_posix.c
  44. 2
      src/core/support/log_linux.c
  45. 2
      src/core/support/log_posix.c
  46. 2
      src/core/support/slice.c
  47. 2
      src/core/support/string.c
  48. 11
      src/core/surface/call.c
  49. 4
      src/core/surface/completion_queue.c
  50. 4
      src/core/surface/init.c
  51. 2
      src/core/transport/chttp2/alpn.c
  52. 2
      src/core/transport/chttp2/alpn.h
  53. 2
      src/core/transport/chttp2/frame_settings.c
  54. 2
      src/core/transport/chttp2/frame_settings.h
  55. 14
      src/core/transport/chttp2/gen_hpack_tables.c
  56. 2
      src/core/transport/metadata.c
  57. 2
      src/core/transport/metadata.h
  58. 88
      src/core/tsi/ssl_transport_security.c
  59. 12
      src/core/tsi/ssl_transport_security.h
  60. 32
      src/core/tsi/transport_security.c
  61. 26
      src/core/tsi/transport_security.h
  62. 39
      src/core/tsi/transport_security_interface.h
  63. 209
      templates/Makefile.template
  64. 2
      test/core/channel/channel_stack_test.c
  65. 2
      test/core/compression/message_compress_test.c
  66. 6
      test/core/echo/server.c
  67. 3
      test/core/end2end/dualstack_socket_test.c
  68. 5
      test/core/end2end/tests/cancel_after_accept.c
  69. 5
      test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
  70. 2
      test/core/end2end/tests/cancel_after_invoke.c
  71. 2
      test/core/end2end/tests/cancel_before_invoke.c
  72. 2
      test/core/end2end/tests/cancel_in_a_vacuum.c
  73. 3
      test/core/end2end/tests/census_simple_request.c
  74. 6
      test/core/end2end/tests/disappearing_server.c
  75. 5
      test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
  76. 2
      test/core/end2end/tests/early_server_shutdown_finishes_tags.c
  77. 5
      test/core/end2end/tests/invoke_large_request.c
  78. 13
      test/core/end2end/tests/max_concurrent_streams.c
  79. 2
      test/core/end2end/tests/no_op.c
  80. 5
      test/core/end2end/tests/ping_pong_streaming.c
  81. 2
      test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
  82. 2
      test/core/end2end/tests/request_response_with_metadata_and_payload.c
  83. 5
      test/core/end2end/tests/request_response_with_payload.c
  84. 2
      test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
  85. 2
      test/core/end2end/tests/request_with_large_metadata.c
  86. 2
      test/core/end2end/tests/request_with_payload.c
  87. 6
      test/core/end2end/tests/simple_delayed_request.c
  88. 8
      test/core/end2end/tests/simple_request.c
  89. 14
      test/core/end2end/tests/thread_stress.c
  90. 5
      test/core/end2end/tests/writes_done_hangs_with_pending_read.c
  91. 10
      test/core/fling/client.c
  92. 5
      test/core/fling/server.c
  93. 8
      test/core/httpcli/format_request_test.c
  94. 6
      test/core/iomgr/alarm_heap_test.c
  95. 6
      test/core/iomgr/alarm_list_test.c
  96. 2
      test/core/iomgr/alarm_test.c
  97. 4
      test/core/iomgr/fd_posix_test.c
  98. 16
      test/core/iomgr/resolve_address_test.c
  99. 8
      test/core/iomgr/sockaddr_utils_test.c
  100. 8
      test/core/iomgr/tcp_client_posix_test.c
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitignore vendored

@ -6,3 +6,6 @@ gens
libs
objs
*.pyc
# cache for run_tests.py
.run_tests_cache

3142
Makefile

File diff suppressed because one or more lines are too long

@ -422,8 +422,8 @@
"c++": true,
"secure": false,
"src": [
"src/compiler/cpp_plugin.cpp",
"src/compiler/cpp_generator.cpp"
"src/compiler/cpp_plugin.cc",
"src/compiler/cpp_generator.cc"
],
"headers": [
"src/compiler/cpp_generator.h",
@ -437,8 +437,8 @@
"c++": true,
"secure": false,
"src": [
"src/compiler/ruby_plugin.cpp",
"src/compiler/ruby_generator.cpp"
"src/compiler/ruby_plugin.cc",
"src/compiler/ruby_generator.cc"
],
"headers": [
"src/compiler/cpp_generator.h",

@ -232,12 +232,12 @@ typedef struct grpc_event {
} grpc_event;
/* Initialize the grpc library */
void grpc_init();
void grpc_init(void);
/* Shutdown the grpc library */
void grpc_shutdown();
void grpc_shutdown(void);
grpc_completion_queue *grpc_completion_queue_create();
grpc_completion_queue *grpc_completion_queue_create(void);
/* Blocks until an event is available, the completion queue is being shutdown,
or deadline is reached. Returns NULL on timeout, otherwise the event that
@ -325,22 +325,6 @@ grpc_call_error grpc_call_start_invoke(grpc_call *call,
void *metadata_read_tag,
void *finished_tag, gpr_uint32 flags);
/* DEPRECATED: users should use grpc_call_server_accept, and
grpc_call_server_end_initial_metadata instead now.
Accept an incoming RPC, binding a completion queue to it.
To be called after adding metadata to the call, but before sending
messages.
flags is a bit-field combination of the write flags defined above.
REQUIRES: Can be called at most once per call.
Can only be called on the server.
Produces a GRPC_FINISHED event with finished_tag when the call has been
completed (there may be other events for the call pending at this
time) */
grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq,
void *finished_tag, gpr_uint32 flags);
/* Accept an incoming RPC, binding a completion queue to it.
To be called before sending or receiving messages.
REQUIRES: Can be called at most once per call.

@ -163,7 +163,7 @@ gpr_slice gpr_slice_split_tail(gpr_slice *s, size_t split);
Requires s intialized, split <= s.length */
gpr_slice gpr_slice_split_head(gpr_slice *s, size_t split);
gpr_slice gpr_empty_slice();
gpr_slice gpr_empty_slice(void);
/* Returns <0 if a < b, ==0 if a == b, >0 if a > b */
int gpr_slice_cmp(gpr_slice a, gpr_slice b);

@ -31,6 +31,9 @@
*
*/
#include <string>
#include <map>
#include "src/compiler/cpp_generator.h"
#include "src/compiler/cpp_generator_helpers.h"
@ -92,8 +95,8 @@ bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
}
} // namespace
string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
string temp =
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
std::string temp =
"#include \"grpc++/impl/internal_stub.h\"\n"
"#include \"grpc++/status.h\"\n"
"\n"
@ -121,7 +124,7 @@ string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
return temp;
}
string GetSourceIncludes() {
std::string GetSourceIncludes() {
return "#include \"grpc++/channel_interface.h\"\n"
"#include \"grpc++/impl/rpc_method.h\"\n"
"#include \"grpc++/impl/rpc_service_method.h\"\n"
@ -130,7 +133,7 @@ string GetSourceIncludes() {
void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
@ -159,7 +162,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
@ -193,7 +196,7 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
void PrintHeaderService(google::protobuf::io::Printer* printer,
const google::protobuf::ServiceDescriptor* service,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(*vars,
@ -238,11 +241,11 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
printer->Print("};\n");
}
string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
string output;
std::string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
std::string output;
google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$');
map<string, string> vars;
std::map<std::string, std::string> vars;
for (int i = 0; i < file->service_count(); ++i) {
PrintHeaderService(&printer, file->service(i), &vars);
@ -253,7 +256,7 @@ string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
@ -311,7 +314,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
const google::protobuf::MethodDescriptor* method,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true);
@ -361,7 +364,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
void PrintSourceService(google::protobuf::io::Printer* printer,
const google::protobuf::ServiceDescriptor* service,
map<string, string>* vars) {
std::map<std::string, std::string>* vars) {
(*vars)["Service"] = service->name();
printer->Print(
*vars,
@ -455,11 +458,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
printer->Print("}\n\n");
}
string GetSourceServices(const google::protobuf::FileDescriptor* file) {
string output;
std::string GetSourceServices(const google::protobuf::FileDescriptor* file) {
std::string output;
google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$');
map<string, string> vars;
std::map<std::string, std::string> vars;
// Package string is empty or ends with a dot. It is used to fully qualify
// method names.
vars["Package"] = file->package();

@ -42,21 +42,19 @@ class FileDescriptor;
} // namespace protobuf
} // namespace google
using namespace std;
namespace grpc_cpp_generator {
// Return the includes needed for generated header file.
string GetHeaderIncludes(const google::protobuf::FileDescriptor* file);
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file);
// Return the includes needed for generated source file.
string GetSourceIncludes();
std::string GetSourceIncludes();
// Return the services for generated header file.
string GetHeaderServices(const google::protobuf::FileDescriptor* file);
std::string GetHeaderServices(const google::protobuf::FileDescriptor* file);
// Return the services for generated source file.
string GetSourceServices(const google::protobuf::FileDescriptor* file);
std::string GetSourceServices(const google::protobuf::FileDescriptor* file);
} // namespace grpc_cpp_generator

@ -39,14 +39,12 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
using namespace std;
namespace grpc_cpp_generator {
inline bool StripSuffix(string* filename, const string& suffix) {
inline bool StripSuffix(std::string* filename, const std::string& suffix) {
if (filename->length() >= suffix.length()) {
size_t suffix_pos = filename->length() - suffix.length();
if (filename->compare(suffix_pos, string::npos, suffix) == 0) {
if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) {
filename->resize(filename->size() - suffix.size());
return true;
}
@ -55,19 +53,20 @@ inline bool StripSuffix(string* filename, const string& suffix) {
return false;
}
inline string StripProto(string filename) {
inline std::string StripProto(std::string filename) {
if (!StripSuffix(&filename, ".protodevel")) {
StripSuffix(&filename, ".proto");
}
return filename;
}
inline string StringReplace(string str, const string& from, const string& to) {
inline std::string StringReplace(std::string str, const std::string& from,
const std::string& to) {
size_t pos = 0;
for (;;) {
pos = str.find(from, pos);
if (pos == string::npos) {
if (pos == std::string::npos) {
break;
}
str.replace(pos, from.length(), to);
@ -77,23 +76,23 @@ inline string StringReplace(string str, const string& from, const string& to) {
return str;
}
inline string DotsToColons(const string& name) {
inline std::string DotsToColons(const std::string& name) {
return StringReplace(name, ".", "::");
}
inline string DotsToUnderscores(const string& name) {
inline std::string DotsToUnderscores(const std::string& name) {
return StringReplace(name, ".", "_");
}
inline string ClassName(const google::protobuf::Descriptor* descriptor,
inline std::string ClassName(const google::protobuf::Descriptor* descriptor,
bool qualified) {
// Find "outer", the descriptor of the top-level message in which
// "descriptor" is embedded.
const google::protobuf::Descriptor* outer = descriptor;
while (outer->containing_type() != NULL) outer = outer->containing_type();
const string& outer_name = outer->full_name();
string inner_name = descriptor->full_name().substr(outer_name.size());
const std::string& outer_name = outer->full_name();
std::string inner_name = descriptor->full_name().substr(outer_name.size());
if (qualified) {
return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name);

@ -35,6 +35,8 @@
//
#include <memory>
#include <string>
#include "src/compiler/cpp_generator.h"
#include "src/compiler/cpp_generator_helpers.h"
#include <google/protobuf/descriptor.h>
@ -50,9 +52,9 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
virtual ~CppGrpcGenerator() {}
virtual bool Generate(const google::protobuf::FileDescriptor* file,
const string& parameter,
const std::string& parameter,
google::protobuf::compiler::GeneratorContext* context,
string* error) const {
std::string* error) const {
if (file->options().cc_generic_services()) {
*error =
"cpp grpc proto compiler plugin does not work with generic "
@ -61,7 +63,7 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
return false;
}
string file_name = grpc_cpp_generator::StripProto(file->name());
std::string file_name = grpc_cpp_generator::StripProto(file->name());
// Generate .pb.h
Insert(context, file_name + ".pb.h", "includes",
@ -80,8 +82,8 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
private:
// Insert the given code into the given file at the given insertion point.
void Insert(google::protobuf::compiler::GeneratorContext* context,
const string& filename, const string& insertion_point,
const string& code) const {
const std::string& filename, const std::string& insertion_point,
const std::string& code) const {
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(filename, insertion_point));
google::protobuf::io::CodedOutputStream coded_out(output.get());

@ -32,6 +32,7 @@
*/
#include <cctype>
#include <string>
#include <map>
#include <vector>
@ -56,17 +57,17 @@ namespace grpc_ruby_generator {
namespace {
// Prints out the method using the ruby gRPC DSL.
void PrintMethod(const MethodDescriptor* method, const string& package,
void PrintMethod(const MethodDescriptor* method, const std::string& package,
Printer* out) {
string input_type = RubyTypeOf(method->input_type()->name(), package);
std::string input_type = RubyTypeOf(method->input_type()->name(), package);
if (method->client_streaming()) {
input_type = "stream(" + input_type + ")";
}
string output_type = RubyTypeOf(method->output_type()->name(), package);
std::string output_type = RubyTypeOf(method->output_type()->name(), package);
if (method->server_streaming()) {
output_type = "stream(" + output_type + ")";
}
map<string, string> method_vars = ListToDict({
std::map<std::string, std::string> method_vars = ListToDict({
"mth.name", method->name(), "input.type", input_type, "output.type",
output_type,
});
@ -74,22 +75,22 @@ void PrintMethod(const MethodDescriptor* method, const string& package,
}
// Prints out the service using the ruby gRPC DSL.
void PrintService(const ServiceDescriptor* service, const string& package,
void PrintService(const ServiceDescriptor* service, const std::string& package,
Printer* out) {
if (service->method_count() == 0) {
return;
}
// Begin the service module
map<string, string> module_vars = ListToDict({
std::map<std::string, std::string> module_vars = ListToDict({
"module.name", CapitalizeFirst(service->name()),
});
out->Print(module_vars, "module $module.name$\n");
out->Indent();
// TODO(temiola): add documentation
string doc = "TODO: add proto service documentation here";
map<string, string> template_vars = ListToDict({
std::string doc = "TODO: add proto service documentation here";
std::map<std::string, std::string> template_vars = ListToDict({
"Documentation", doc,
});
out->Print("\n");
@ -103,7 +104,7 @@ void PrintService(const ServiceDescriptor* service, const string& package,
out->Print("\n");
out->Print("self.marshal_class_method = :encode\n");
out->Print("self.unmarshal_class_method = :decode\n");
map<string, string> pkg_vars = ListToDict({
std::map<std::string, std::string> pkg_vars = ListToDict({
"service.name", service->name(), "pkg.name", package,
});
out->Print(pkg_vars, "self.service_name = '$pkg.name$.$service.name$'\n");
@ -124,8 +125,8 @@ void PrintService(const ServiceDescriptor* service, const string& package,
} // namespace
string GetServices(const FileDescriptor* file) {
string output;
std::string GetServices(const FileDescriptor* file) {
std::string output;
StringOutputStream output_stream(&output);
Printer out(&output_stream, '$');
@ -136,7 +137,7 @@ string GetServices(const FileDescriptor* file) {
}
// Write out a file header.
map<string, string> header_comment_vars = ListToDict({
std::map<std::string, std::string> header_comment_vars = ListToDict({
"file.name", file->name(), "file.package", file->package(),
});
out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n");
@ -148,16 +149,16 @@ string GetServices(const FileDescriptor* file) {
// Write out require statemment to import the separately generated file
// that defines the messages used by the service. This is generated by the
// main ruby plugin.
map<string, string> dep_vars = ListToDict({
std::map<std::string, std::string> dep_vars = ListToDict({
"dep.name", MessagesRequireName(file),
});
out.Print(dep_vars, "require '$dep.name$'\n");
// Write out services within the modules
out.Print("\n");
vector<string> modules = Split(file->package(), '.');
std::vector<std::string> modules = Split(file->package(), '.');
for (size_t i = 0; i < modules.size(); ++i) {
map<string, string> module_vars = ListToDict({
std::map<std::string, std::string> module_vars = ListToDict({
"module.name", CapitalizeFirst(modules[i]),
});
out.Print(module_vars, "module $module.name$\n");

@ -36,8 +36,6 @@
#include <string>
using namespace std;
namespace google {
namespace protobuf {
class FileDescriptor;
@ -46,7 +44,7 @@ class FileDescriptor;
namespace grpc_ruby_generator {
string GetServices(const google::protobuf::FileDescriptor* file);
std::string GetServices(const google::protobuf::FileDescriptor* file);
} // namespace grpc_ruby_generator

@ -42,7 +42,7 @@
namespace grpc_ruby_generator {
inline bool ServicesFilename(const google::protobuf::FileDescriptor* file,
string* file_name_or_error) {
std::string* file_name_or_error) {
// Get output file name.
static const unsigned proto_suffix_length = 6; // length of ".proto"
if (file->name().size() > proto_suffix_length &&
@ -57,7 +57,7 @@ inline bool ServicesFilename(const google::protobuf::FileDescriptor* file,
}
}
inline string MessagesRequireName(
inline std::string MessagesRequireName(
const google::protobuf::FileDescriptor* file) {
return Replace(file->name(), ".proto", "");
}

@ -48,17 +48,18 @@ namespace grpc_ruby_generator {
// Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code.
inline map<string, string> ListToDict(const initializer_list<string>& values) {
inline std::map<std::string, std::string> ListToDict(
const initializer_list<std::string>& values) {
if (values.size() % 2 != 0) {
// MOE: insert std::cerr << "Not every 'key' has a value in `values`."
// << std::endl;
}
map<string, string> value_map;
std::map<std::string, std::string> value_map;
auto value_iter = values.begin();
for (unsigned i = 0; i < values.size() / 2; ++i) {
string key = *value_iter;
std::string key = *value_iter;
++value_iter;
string value = *value_iter;
std::string value = *value_iter;
value_map[key] = value;
++value_iter;
}

@ -45,10 +45,10 @@ using std::transform;
namespace grpc_ruby_generator {
// Split splits a string using char into elems.
inline vector<string>& Split(const string& s, char delim,
vector<string>* elems) {
stringstream ss(s);
string item;
inline std::vector<std::string>& Split(const std::string& s, char delim,
std::vector<std::string>* elems) {
std::stringstream ss(s);
std::string item;
while (getline(ss, item, delim)) {
elems->push_back(item);
}
@ -56,16 +56,17 @@ inline vector<string>& Split(const string& s, char delim,
}
// Split splits a string using char, returning the result in a vector.
inline vector<string> Split(const string& s, char delim) {
vector<string> elems;
inline std::vector<std::string> Split(const std::string& s, char delim) {
std::vector<std::string> elems;
Split(s, delim, &elems);
return elems;
}
// Replace replaces from with to in s.
inline string Replace(string s, const string& from, const string& to) {
inline std::string Replace(std::string s, const std::string& from,
const std::string& to) {
size_t start_pos = s.find(from);
if (start_pos == string::npos) {
if (start_pos == std::string::npos) {
return s;
}
s.replace(start_pos, from.length(), to);
@ -73,10 +74,10 @@ inline string Replace(string s, const string& from, const string& to) {
}
// ReplaceAll replaces all instances of search with replace in s.
inline string ReplaceAll(string s, const string& search,
const string& replace) {
inline std::string ReplaceAll(std::string s, const std::string& search,
const std::string& replace) {
size_t pos = 0;
while ((pos = s.find(search, pos)) != string::npos) {
while ((pos = s.find(search, pos)) != std::string::npos) {
s.replace(pos, search.length(), replace);
pos += replace.length();
}
@ -84,9 +85,10 @@ inline string ReplaceAll(string s, const string& search,
}
// ReplacePrefix replaces from with to in s if search is a prefix of s.
inline bool ReplacePrefix(string* s, const string& from, const string& to) {
inline bool ReplacePrefix(std::string* s, const std::string& from,
const std::string& to) {
size_t start_pos = s->find(from);
if (start_pos == string::npos || start_pos != 0) {
if (start_pos == std::string::npos || start_pos != 0) {
return false;
}
s->replace(start_pos, from.length(), to);
@ -94,7 +96,7 @@ inline bool ReplacePrefix(string* s, const string& from, const string& to) {
}
// CapitalizeFirst capitalizes the first char in a string.
inline string CapitalizeFirst(string s) {
inline std::string CapitalizeFirst(std::string s) {
if (s.empty()) {
return s;
}
@ -103,14 +105,15 @@ inline string CapitalizeFirst(string s) {
}
// RubyTypeOf updates a proto type to the required ruby equivalent.
inline string RubyTypeOf(const string& a_type, const string& package) {
string res(a_type);
inline std::string RubyTypeOf(const std::string& a_type,
const std::string& package) {
std::string res(a_type);
ReplacePrefix(&res, package, ""); // remove the leading package if present
ReplacePrefix(&res, ".", ""); // remove the leading . (no package)
if (res.find('.') == string::npos) {
if (res.find('.') == std::string::npos) {
return res;
} else {
vector<string> prefixes_and_type = Split(res, '.');
std::vector<std::string> prefixes_and_type = Split(res, '.');
for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) {
if (i != 0) {
res += "::"; // switch '.' to the ruby module delim

@ -37,6 +37,7 @@
// and net/proto2/compiler/public/plugin.h for more information on plugins.
#include <memory>
#include <string>
#include "src/compiler/ruby_generator.h"
#include "src/compiler/ruby_generator_helpers-inl.h"
@ -52,16 +53,16 @@ class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
~RubyGrpcGenerator() override {}
bool Generate(const google::protobuf::FileDescriptor* file,
const string& parameter,
const std::string& parameter,
google::protobuf::compiler::GeneratorContext* context,
string* error) const override {
string code = grpc_ruby_generator::GetServices(file);
std::string* error) const override {
std::string code = grpc_ruby_generator::GetServices(file);
if (code.size() == 0) {
return true; // don't generate a file if there are no services
}
// Get output file name.
string file_name;
std::string file_name;
if (!grpc_ruby_generator::ServicesFilename(file, &file_name)) {
return false;
}

@ -100,7 +100,7 @@ void grpc_alarm_list_init(gpr_timespec now) {
}
}
void grpc_alarm_list_shutdown() {
void grpc_alarm_list_shutdown(void) {
int i;
while (run_some_expired_alarms(NULL, gpr_inf_future, NULL, 0))
;
@ -360,7 +360,7 @@ int grpc_alarm_check(gpr_mu *drop_mu, gpr_timespec now, gpr_timespec *next) {
return run_some_expired_alarms(drop_mu, now, next, 1);
}
gpr_timespec grpc_alarm_list_next_timeout() {
gpr_timespec grpc_alarm_list_next_timeout(void) {
gpr_timespec out;
gpr_mu_lock(&g_mu);
out = g_shard_queue[0]->min_deadline;

@ -42,12 +42,12 @@
int grpc_alarm_check(gpr_mu *drop_mu, gpr_timespec now, gpr_timespec *next);
void grpc_alarm_list_init(gpr_timespec now);
void grpc_alarm_list_shutdown();
void grpc_alarm_list_shutdown(void);
gpr_timespec grpc_alarm_list_next_timeout();
gpr_timespec grpc_alarm_list_next_timeout(void);
/* the following must be implemented by each iomgr implementation */
void grpc_kick_poller();
void grpc_kick_poller(void);
#endif /* __GRPC_INTERNAL_IOMGR_ALARM_INTERNAL_H_ */

@ -80,9 +80,9 @@ static void background_callback_executor(void *ignored) {
gpr_event_set(&g_background_callback_executor_done, (void *)1);
}
void grpc_kick_poller() { gpr_cv_broadcast(&g_cv); }
void grpc_kick_poller(void) { gpr_cv_broadcast(&g_cv); }
void grpc_iomgr_init() {
void grpc_iomgr_init(void) {
gpr_thd_id id;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_cv);
@ -93,7 +93,7 @@ void grpc_iomgr_init() {
gpr_thd_new(&id, background_callback_executor, NULL, NULL);
}
void grpc_iomgr_shutdown() {
void grpc_iomgr_shutdown(void) {
delayed_callback *cb;
gpr_timespec shutdown_deadline =
gpr_time_add(gpr_now(), gpr_time_from_seconds(10));
@ -134,13 +134,13 @@ void grpc_iomgr_shutdown() {
gpr_cv_destroy(&g_cv);
}
void grpc_iomgr_ref() {
void grpc_iomgr_ref(void) {
gpr_mu_lock(&g_mu);
++g_refs;
gpr_mu_unlock(&g_mu);
}
void grpc_iomgr_unref() {
void grpc_iomgr_unref(void) {
gpr_mu_lock(&g_mu);
if (0 == --g_refs) {
gpr_cv_signal(&g_cv);

@ -37,8 +37,8 @@
/* gRPC Callback definition */
typedef void (*grpc_iomgr_cb_func)(void *arg, int success);
void grpc_iomgr_init();
void grpc_iomgr_shutdown();
void grpc_iomgr_init(void);
void grpc_iomgr_shutdown(void);
/* This function is called from within a callback or from anywhere else
and causes the invocation of a callback at some point in the future */

@ -42,10 +42,10 @@ int grpc_maybe_call_delayed_callbacks(gpr_mu *drop_mu, int success);
void grpc_iomgr_add_delayed_callback(grpc_iomgr_cb_func cb, void *cb_arg,
int success);
void grpc_iomgr_ref();
void grpc_iomgr_unref();
void grpc_iomgr_ref(void);
void grpc_iomgr_unref(void);
void grpc_iomgr_platform_init();
void grpc_iomgr_platform_shutdown();
void grpc_iomgr_platform_init(void);
void grpc_iomgr_platform_shutdown(void);
#endif /* __GRPC_INTERNAL_IOMGR_IOMGR_INTERNAL_H_ */

@ -33,6 +33,6 @@
#include "src/core/iomgr/iomgr_posix.h"
void grpc_iomgr_platform_init() { grpc_pollset_global_init(); }
void grpc_iomgr_platform_init(void) { grpc_pollset_global_init(); }
void grpc_iomgr_platform_shutdown() { grpc_pollset_global_shutdown(); }
void grpc_iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); }

@ -36,7 +36,7 @@
#include "src/core/iomgr/iomgr_internal.h"
void grpc_pollset_global_init();
void grpc_pollset_global_shutdown();
void grpc_pollset_global_init(void);
void grpc_pollset_global_shutdown(void);
#endif /* __GRPC_INTERNAL_IOMGR_IOMGR_POSIX_H_ */

@ -129,9 +129,9 @@ void grpc_kick_drain(grpc_pollset *p) {
/* global state management */
grpc_pollset *grpc_backup_pollset() { return &g_backup_pollset; }
grpc_pollset *grpc_backup_pollset(void) { return &g_backup_pollset; }
void grpc_pollset_global_init() {
void grpc_pollset_global_init(void) {
int i;
gpr_thd_id id;
@ -151,7 +151,7 @@ void grpc_pollset_global_init() {
gpr_thd_new(&id, backup_poller, NULL, NULL);
}
void grpc_pollset_global_shutdown() {
void grpc_pollset_global_shutdown(void) {
int i;
/* terminate the backup poller thread */

@ -86,7 +86,7 @@ void grpc_kick_drain(grpc_pollset *p);
regardless of applications listening to events. Relying on this is slow
however (the backup pollset only listens every 100ms or so) - so it's not
to be relied on. */
grpc_pollset *grpc_backup_pollset();
grpc_pollset *grpc_backup_pollset(void);
/* turn a pollset into a multipoller: platform specific */
void grpc_platform_become_multipoller(grpc_pollset *pollset,

@ -115,7 +115,7 @@ int grpc_set_socket_low_latency(int fd, int low_latency) {
static gpr_once g_probe_ipv6_once = GPR_ONCE_INIT;
static int g_ipv6_loopback_available;
static void probe_ipv6_once() {
static void probe_ipv6_once(void) {
int fd = socket(AF_INET6, SOCK_STREAM, 0);
g_ipv6_loopback_available = 0;
if (fd < 0) {
@ -135,7 +135,7 @@ static void probe_ipv6_once() {
}
}
int grpc_ipv6_loopback_available() {
int grpc_ipv6_loopback_available(void) {
gpr_once_init(&g_probe_ipv6_once, probe_ipv6_once);
return g_ipv6_loopback_available;
}

@ -61,7 +61,7 @@ int grpc_set_socket_low_latency(int fd, int low_latency);
and bind IPv6 sockets, but cannot connect to a getsockname() of [::]:port
without a valid loopback interface. Rather than expose this half-broken
state to library users, we turn off IPv6 sockets. */
int grpc_ipv6_loopback_available();
int grpc_ipv6_loopback_available(void);
/* An enum to keep track of IPv4/IPv6 socket modes.

@ -46,7 +46,7 @@ typedef struct grpc_tcp_server grpc_tcp_server;
typedef void (*grpc_tcp_server_cb)(void *arg, grpc_endpoint *ep);
/* Create a server, initially not bound to any ports */
grpc_tcp_server *grpc_tcp_server_create();
grpc_tcp_server *grpc_tcp_server_create(void);
/* Start listening to bound ports */
void grpc_tcp_server_start(grpc_tcp_server *server, grpc_pollset *pollset,

@ -84,7 +84,7 @@ struct grpc_tcp_server {
size_t port_capacity;
};
grpc_tcp_server *grpc_tcp_server_create() {
grpc_tcp_server *grpc_tcp_server_create(void) {
grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
gpr_mu_init(&s->mu);
gpr_cv_init(&s->cv);
@ -120,7 +120,7 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s) {
}
/* get max listen queue size on linux */
static void init_max_accept_queue_size() {
static void init_max_accept_queue_size(void) {
int n = SOMAXCONN;
char buf[64];
FILE *fp = fopen("/proc/sys/net/core/somaxconn", "r");
@ -147,7 +147,7 @@ static void init_max_accept_queue_size() {
}
}
static int get_max_accept_queue_size() {
static int get_max_accept_queue_size(void) {
gpr_once_init(&s_init_max_accept_queue_size, init_max_accept_queue_size);
return s_max_accept_queue_size;
}

@ -637,8 +637,8 @@ grpc_credentials *grpc_fake_transport_security_credentials_create(void) {
return c;
}
grpc_server_credentials *
grpc_fake_transport_security_server_credentials_create() {
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
void) {
grpc_server_credentials *c = gpr_malloc(sizeof(grpc_server_credentials));
memset(c, 0, sizeof(grpc_server_credentials));
c->type = GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;

@ -126,8 +126,8 @@ static void on_read(void *user_data, gpr_slice *slices, size_t nslices,
size_t message_size = GPR_SLICE_LENGTH(encrypted);
while (message_size > 0 || keep_looping) {
gpr_uint32 unprotected_buffer_size_written = end - cur;
gpr_uint32 processed_message_size = message_size;
size_t unprotected_buffer_size_written = end - cur;
size_t processed_message_size = message_size;
gpr_mu_lock(&ep->protector_mu);
result = tsi_frame_protector_unprotect(ep->protector, message_bytes,
&processed_message_size, cur,
@ -245,8 +245,8 @@ static grpc_endpoint_write_status endpoint_write(grpc_endpoint *secure_ep,
gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(plain);
size_t message_size = GPR_SLICE_LENGTH(plain);
while (message_size > 0) {
gpr_uint32 protected_buffer_size_to_send = end - cur;
gpr_uint32 processed_message_size = message_size;
size_t protected_buffer_size_to_send = end - cur;
size_t processed_message_size = message_size;
gpr_mu_lock(&ep->protector_mu);
result = tsi_frame_protector_protect(ep->protector, message_bytes,
&processed_message_size, cur,
@ -268,9 +268,9 @@ static grpc_endpoint_write_status endpoint_write(grpc_endpoint *secure_ep,
if (result != TSI_OK) break;
}
if (result == TSI_OK) {
gpr_uint32 still_pending_size;
size_t still_pending_size;
do {
gpr_uint32 protected_buffer_size_to_send = end - cur;
size_t protected_buffer_size_to_send = end - cur;
gpr_mu_lock(&ep->protector_mu);
result = tsi_frame_protector_protect_flush(ep->protector, cur,
&protected_buffer_size_to_send,

@ -131,7 +131,7 @@ static void send_handshake_bytes_to_peer(grpc_secure_transport_setup *s) {
grpc_endpoint_write_status write_status;
do {
uint32_t to_send_size = s->handshake_buffer_size - offset;
size_t to_send_size = s->handshake_buffer_size - offset;
result = tsi_handshaker_get_bytes_to_send_to_peer(
s->handshaker, s->handshake_buffer + offset, &to_send_size);
offset += to_send_size;
@ -174,7 +174,7 @@ static void on_handshake_data_received_from_peer(
void *setup, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status error) {
grpc_secure_transport_setup *s = setup;
uint32_t consumed_slice_size = 0;
size_t consumed_slice_size = 0;
tsi_result result = TSI_OK;
size_t i;
size_t num_left_overs;

@ -411,9 +411,9 @@ grpc_security_status grpc_ssl_server_security_context_create(
c->base.vtable = &ssl_server_vtable;
result = tsi_create_ssl_server_handshaker_factory(
(const unsigned char **)&config->pem_private_key,
(const gpr_uint32 *)&config->pem_private_key_size,
&config->pem_private_key_size,
(const unsigned char **)&config->pem_cert_chain,
(const gpr_uint32 *)&config->pem_cert_chain_size, 1,
&config->pem_cert_chain_size, 1,
config->pem_root_certs, config->pem_root_certs_size,
GRPC_SSL_CIPHER_SUITES, alpn_protocol_strings,
alpn_protocol_string_lengths, num_alpn_protocols, &c->handshaker_factory);

@ -37,13 +37,13 @@
#include "src/core/statistics/census_rpc_stats.h"
#include "src/core/statistics/census_tracing.h"
void census_init() {
void census_init(void) {
gpr_log(GPR_INFO, "Initialize census library.");
census_tracing_init();
census_stats_store_init();
}
void census_shutdown() {
void census_shutdown(void) {
gpr_log(GPR_INFO, "Shutdown census library.");
census_stats_store_shutdown();
census_tracing_shutdown();

@ -49,10 +49,10 @@ typedef struct census_op_id {
typedef struct census_rpc_stats census_rpc_stats;
/* Initializes Census library. No-op if Census is already initialized. */
void census_init();
void census_init(void);
/* Shutdown Census Library. */
void census_shutdown();
void census_shutdown(void);
/* Annotates grpc method name on a census_op_id. The method name has the format
of <full quantified rpc service name>/<rpc function name>. Returns 0 iff
@ -68,7 +68,7 @@ int census_add_method_tag(census_op_id op_id, const char* method_name);
void census_tracing_print(census_op_id op_id, const char* annotation);
/* Starts tracing for an RPC. Returns a locally unique census_op_id */
census_op_id census_tracing_start_op();
census_op_id census_tracing_start_op(void);
/* Ends tracing. Calling this function will invalidate the input op_id. */
void census_tracing_end_op(census_op_id op_id);

@ -368,7 +368,7 @@ static void cl_block_end_read(cl_block* block) {
/* Allocates a new free block (or recycles an available dirty block if log is
configured to discard old records). Returns NULL if out-of-space. */
static cl_block* cl_allocate_block() {
static cl_block* cl_allocate_block(void) {
cl_block* block = cl_block_list_head(&g_log.free_block_list);
if (block != NULL) {
cl_block_list_remove(&g_log.free_block_list, block);
@ -496,7 +496,7 @@ void census_log_initialize(size_t size_in_mb, int discard_old_records) {
g_log.initialized = 1;
}
void census_log_shutdown() {
void census_log_shutdown(void) {
GPR_ASSERT(g_log.initialized);
gpr_mu_destroy(&g_log.lock);
gpr_free_aligned(g_log.core_local_blocks);
@ -551,7 +551,7 @@ void census_log_end_write(void* record, size_t bytes_written) {
cl_block_end_write(cl_get_block(record), bytes_written);
}
void census_log_init_reader() {
void census_log_init_reader(void) {
GPR_ASSERT(g_log.initialized);
gpr_mu_lock(&g_log.lock);
/* If a block is locked for reading unlock it. */
@ -584,7 +584,7 @@ const void* census_log_read_next(size_t* bytes_available) {
return NULL;
}
size_t census_log_remaining_space() {
size_t census_log_remaining_space(void) {
size_t space;
GPR_ASSERT(g_log.initialized);
gpr_mu_lock(&g_log.lock);
@ -598,7 +598,7 @@ size_t census_log_remaining_space() {
return space;
}
int census_log_out_of_space_count() {
int census_log_out_of_space_count(void) {
GPR_ASSERT(g_log.initialized);
return gpr_atm_acq_load(&g_log.out_of_space_count);
}

@ -53,7 +53,7 @@ void census_log_initialize(size_t size_in_mb, int discard_old_records);
- no in progress or future call to any census_log functions
- no incomplete records
*/
void census_log_shutdown();
void census_log_shutdown(void);
/* Allocates and returns a 'size' bytes record and marks it in use. A
subsequent census_log_end_write() marks the record complete. The
@ -74,7 +74,7 @@ void census_log_end_write(void* record, size_t bytes_written);
is read. census_log_init_reader() starts the iteration or aborts the
current iteration.
*/
void census_log_init_reader();
void census_log_init_reader(void);
const void* census_log_read_next(size_t* bytes_available);
/* Returns estimated remaining space across all blocks, in bytes. If log is
@ -82,10 +82,10 @@ const void* census_log_read_next(size_t* bytes_available);
returns space available in empty blocks (partially filled blocks are
treated as full).
*/
size_t census_log_remaining_space();
size_t census_log_remaining_space(void);
/* Returns the number of times gprc_stats_log_start_write() failed due to
out-of-space. */
int census_log_out_of_space_count();
int census_log_out_of_space_count(void);
#endif /* __GRPC_INTERNAL_STATISTICS_LOG_H__ */

@ -59,9 +59,9 @@ static gpr_mu g_mu;
static census_ht* g_client_stats_store = NULL;
static census_ht* g_server_stats_store = NULL;
static void init_mutex() { gpr_mu_init(&g_mu); }
static void init_mutex(void) { gpr_mu_init(&g_mu); }
static void init_mutex_once() {
static void init_mutex_once(void) {
gpr_once_init(&g_stats_store_mu_init, init_mutex);
}
@ -115,7 +115,7 @@ static gpr_timespec min_hour_total_intervals[3] = {
static const census_window_stats_stat_info window_stats_settings = {
sizeof(census_rpc_stats), init_rpc_stats, stat_add, stat_add_proportion};
census_rpc_stats* census_rpc_stats_create_empty() {
census_rpc_stats* census_rpc_stats_create_empty(void) {
census_rpc_stats* ret =
(census_rpc_stats*)gpr_malloc(sizeof(census_rpc_stats));
memset(ret, 0, sizeof(census_rpc_stats));
@ -220,7 +220,7 @@ void census_get_server_stats(census_aggregated_rpc_stats* data) {
get_stats(g_server_stats_store, data);
}
void census_stats_store_init() {
void census_stats_store_init(void) {
gpr_log(GPR_INFO, "Initialize census stats store.");
init_mutex_once();
gpr_mu_lock(&g_mu);
@ -233,7 +233,7 @@ void census_stats_store_init() {
gpr_mu_unlock(&g_mu);
}
void census_stats_store_shutdown() {
void census_stats_store_shutdown(void) {
gpr_log(GPR_INFO, "Shutdown census stats store.");
init_mutex_once();
gpr_mu_lock(&g_mu);

@ -53,7 +53,7 @@ struct census_rpc_stats {
};
/* Creates an empty rpc stats object on heap. */
census_rpc_stats* census_rpc_stats_create_empty();
census_rpc_stats* census_rpc_stats_create_empty(void);
typedef struct census_per_method_rpc_stats {
const char* method;
@ -91,8 +91,8 @@ void census_get_server_stats(census_aggregated_rpc_stats* data_map);
DO NOT CALL from outside of grpc code. */
void census_get_client_stats(census_aggregated_rpc_stats* data_map);
void census_stats_store_init();
void census_stats_store_shutdown();
void census_stats_store_init(void);
void census_stats_store_shutdown(void);
#ifdef __cplusplus
}

@ -93,11 +93,13 @@ static gpr_uint64 op_id_2_uint64(census_op_id* id) {
return ret;
}
static void init_mutex() { gpr_mu_init(&g_mu); }
static void init_mutex(void) { gpr_mu_init(&g_mu); }
static void init_mutex_once() { gpr_once_init(&g_init_mutex_once, init_mutex); }
static void init_mutex_once(void) {
gpr_once_init(&g_init_mutex_once, init_mutex);
}
census_op_id census_tracing_start_op() {
census_op_id census_tracing_start_op(void) {
gpr_mu_lock(&g_mu);
{
trace_obj* ret = (trace_obj*)gpr_malloc(sizeof(trace_obj));
@ -164,7 +166,7 @@ void census_tracing_end_op(census_op_id op_id) {
gpr_mu_unlock(&g_mu);
}
void census_tracing_init() {
void census_tracing_init(void) {
gpr_log(GPR_INFO, "Initialize census trace store.");
init_mutex_once();
gpr_mu_lock(&g_mu);
@ -177,7 +179,7 @@ void census_tracing_init() {
gpr_mu_unlock(&g_mu);
}
void census_tracing_shutdown() {
void census_tracing_shutdown(void) {
gpr_log(GPR_INFO, "Shutdown census trace store.");
gpr_mu_lock(&g_mu);
if (g_trace_store != NULL) {
@ -189,9 +191,9 @@ void census_tracing_shutdown() {
gpr_mu_unlock(&g_mu);
}
void census_internal_lock_trace_store() { gpr_mu_lock(&g_mu); }
void census_internal_lock_trace_store(void) { gpr_mu_lock(&g_mu); }
void census_internal_unlock_trace_store() { gpr_mu_unlock(&g_mu); }
void census_internal_unlock_trace_store(void) { gpr_mu_unlock(&g_mu); }
trace_obj* census_get_trace_obj_locked(census_op_id op_id) {
if (g_trace_store == NULL) {

@ -38,10 +38,10 @@
typedef struct trace_obj trace_obj;
/* Initializes trace store. This function is thread safe. */
void census_tracing_init();
void census_tracing_init(void);
/* Shutsdown trace store. This function is thread safe. */
void census_tracing_shutdown();
void census_tracing_shutdown(void);
/* Gets trace obj corresponding to the input op_id. Returns NULL if trace store
is not initialized or trace obj is not found. Requires trace store being
@ -50,8 +50,8 @@ trace_obj* census_get_trace_obj_locked(census_op_id op_id);
/* The following two functions acquire and release the trace store global lock.
They are for census internal use only. */
void census_internal_lock_trace_store();
void census_internal_unlock_trace_store();
void census_internal_lock_trace_store(void);
void census_internal_unlock_trace_store(void);
/* Gets method tag name associated with the input trace object. */
const char* census_get_trace_method_name(const trace_obj* trace);

@ -38,12 +38,12 @@
/* Return the number of CPU cores on the current system. Will return 0 if
if information is not available. */
int gpr_cpu_num_cores();
int gpr_cpu_num_cores(void);
/* Return the CPU on which the current thread is executing; N.B. This should
be considered advisory only - it is possible that the thread is switched
to a different CPU at any time. Returns a value in range
[0, gpr_cpu_num_cores() - 1] */
int gpr_cpu_current_cpu();
int gpr_cpu_current_cpu(void);
#endif /* __GRPC_INTERNAL_SUPPORT_CPU_H__ */

@ -75,7 +75,7 @@
#include <grpc/support/log.h>
int gpr_cpu_num_cores() {
int gpr_cpu_num_cores(void) {
static int ncpus = 0;
if (ncpus == 0) {
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
@ -87,7 +87,7 @@ int gpr_cpu_num_cores() {
return ncpus;
}
int gpr_cpu_current_cpu() {
int gpr_cpu_current_cpu(void) {
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));

@ -45,7 +45,7 @@
static __thread char magic_thread_local;
int gpr_cpu_num_cores() {
int gpr_cpu_num_cores(void) {
static int ncpus = 0;
if (ncpus == 0) {
ncpus = sysconf(_SC_NPROCESSORS_ONLN);
@ -63,7 +63,7 @@ static size_t shard_ptr(const void *info) {
return ((x >> 4) ^ (x >> 9) ^ (x >> 14)) % gpr_cpu_num_cores();
}
int gpr_cpu_current_cpu() {
int gpr_cpu_current_cpu(void) {
/* NOTE: there's no way I know to return the actual cpu index portably...
most code that's using this is using it to shard across work queues though,
so here we use thread identity instead to achieve a similar though not

@ -47,7 +47,7 @@
#include <sys/syscall.h>
#include <unistd.h>
static long gettid() { return syscall(__NR_gettid); }
static long gettid(void) { return syscall(__NR_gettid); }
void gpr_log(const char *file, int line, gpr_log_severity severity,
const char *format, ...) {

@ -50,7 +50,7 @@
#include <time.h>
#include <pthread.h>
static gpr_intptr gettid() { return (gpr_intptr)pthread_self(); }
static gpr_intptr gettid(void) { return (gpr_intptr)pthread_self(); }
void gpr_log(const char *file, int line, gpr_log_severity severity,
const char *format, ...) {

@ -37,7 +37,7 @@
#include <string.h>
gpr_slice gpr_empty_slice() {
gpr_slice gpr_empty_slice(void) {
gpr_slice out;
out.refcount = 0;
out.data.inlined.length = 0;

@ -63,7 +63,7 @@ typedef struct {
char *data;
} hexout;
static hexout hexout_create() {
static hexout hexout_create(void) {
hexout r = {0, 0, NULL};
return r;
}

@ -535,17 +535,6 @@ grpc_call_error grpc_call_server_end_initial_metadata(grpc_call *call,
return GRPC_CALL_OK;
}
grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq,
void *finished_tag, gpr_uint32 flags) {
grpc_call_error err;
err = grpc_call_server_accept(call, cq, finished_tag);
if (err != GRPC_CALL_OK) return err;
err = grpc_call_server_end_initial_metadata(call, flags);
if (err != GRPC_CALL_OK) return err;
return GRPC_CALL_OK;
}
static void done_writes_done(void *user_data, grpc_op_error error) {
grpc_call *call = user_data;
void *tag = call->write_tag;

@ -85,7 +85,7 @@ struct grpc_completion_queue {
/* Default do-nothing on_finish function */
static void null_on_finish(void *user_data, grpc_op_error error) {}
grpc_completion_queue *grpc_completion_queue_create() {
grpc_completion_queue *grpc_completion_queue_create(void) {
grpc_completion_queue *cc = gpr_malloc(sizeof(grpc_completion_queue));
memset(cc, 0, sizeof(*cc));
/* Initial ref is dropped by grpc_completion_queue_shutdown */
@ -251,7 +251,7 @@ void grpc_cq_end_new_rpc(grpc_completion_queue *cc, void *tag, grpc_call *call,
}
/* Create a GRPC_QUEUE_SHUTDOWN event without queuing it anywhere */
static event *create_shutdown_event() {
static event *create_shutdown_event(void) {
event *ev = gpr_malloc(sizeof(event));
ev->base.type = GRPC_QUEUE_SHUTDOWN;
ev->base.call = NULL;

@ -35,12 +35,12 @@
#include "src/core/statistics/census_interface.h"
#include "src/core/iomgr/iomgr.h"
void grpc_init() {
void grpc_init(void) {
grpc_iomgr_init();
census_init();
}
void grpc_shutdown() {
void grpc_shutdown(void) {
grpc_iomgr_shutdown();
census_shutdown();
}

@ -46,7 +46,7 @@ int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
return 0;
}
size_t grpc_chttp2_num_alpn_versions() {
size_t grpc_chttp2_num_alpn_versions(void) {
return GPR_ARRAY_SIZE(supported_versions);
}

@ -40,7 +40,7 @@
int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size);
/* Returns the number of protocol versions to advertise */
size_t grpc_chttp2_num_alpn_versions();
size_t grpc_chttp2_num_alpn_versions(void);
/* Returns the protocol version at index i (0 <= i <
* grpc_chttp2_num_alpn_versions()) */

@ -102,7 +102,7 @@ gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
return output;
}
gpr_slice grpc_chttp2_settings_ack_create() {
gpr_slice grpc_chttp2_settings_ack_create(void) {
gpr_slice output = gpr_slice_malloc(9);
fill_header(GPR_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK);
return output;

@ -88,7 +88,7 @@ extern const grpc_chttp2_setting_parameters
gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
gpr_uint32 force_mask, size_t count);
/* Create an ack settings frame */
gpr_slice grpc_chttp2_settings_ack_create();
gpr_slice grpc_chttp2_settings_ack_create(void);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,

@ -86,7 +86,7 @@ static unsigned char suffix_mask(unsigned char prefix_len) {
return ~prefix_mask(prefix_len);
}
static void generate_first_byte_lut() {
static void generate_first_byte_lut(void) {
int i, j, n;
const spec *chrspec;
unsigned char suffix;
@ -136,21 +136,21 @@ typedef struct { char included[GRPC_CHTTP2_NUM_HUFFSYMS]; } symset;
typedef struct { int values[16]; } nibblelut;
/* returns a symset that includes all possible symbols */
static symset symset_all() {
static symset symset_all(void) {
symset x;
memset(x.included, 1, sizeof(x.included));
return x;
}
/* returns a symset that includes no symbols */
static symset symset_none() {
static symset symset_none(void) {
symset x;
memset(x.included, 0, sizeof(x.included));
return x;
}
/* returns an empty nibblelut */
static nibblelut nibblelut_empty() {
static nibblelut nibblelut_empty(void) {
nibblelut x;
int i;
for (i = 0; i < 16; i++) {
@ -296,7 +296,7 @@ static void dump_ctbl(const char *name) {
printf("};\n");
}
static void generate_huff_tables() {
static void generate_huff_tables(void) {
int i;
build_dec_tbl(state_index(0, symset_all(), &i), 0, 0, 0, -1, symset_all());
@ -317,7 +317,7 @@ static void generate_huff_tables() {
dump_ctbl("emit_sub_tbl");
}
static void generate_base64_huff_encoder_table() {
static void generate_base64_huff_encoder_table(void) {
static const char alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int i;
@ -332,7 +332,7 @@ static void generate_base64_huff_encoder_table() {
printf("};\n");
}
static void generate_base64_inverse_table() {
static void generate_base64_inverse_table(void) {
static const char alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
unsigned char inverse[256];

@ -154,7 +154,7 @@ grpc_mdctx *grpc_mdctx_create_with_seed(gpr_uint32 seed) {
return ctx;
}
grpc_mdctx *grpc_mdctx_create() {
grpc_mdctx *grpc_mdctx_create(void) {
/* This seed is used to prevent remote connections from controlling hash table
* collisions. It needs to be somewhat unpredictable to a remote connection.
*/

@ -82,7 +82,7 @@ struct grpc_mdelem {
};
/* Create/orphan a metadata context */
grpc_mdctx *grpc_mdctx_create();
grpc_mdctx *grpc_mdctx_create(void);
grpc_mdctx *grpc_mdctx_create_with_seed(gpr_uint32 seed);
void grpc_mdctx_orphan(grpc_mdctx *mdctx);

@ -76,9 +76,9 @@ typedef struct {
associated with the contexts at the same index. */
SSL_CTX** ssl_contexts;
tsi_peer* ssl_context_x509_subject_names;
uint32_t ssl_context_count;
size_t ssl_context_count;
unsigned char* alpn_protocol_list;
uint32_t alpn_protocol_list_length;
size_t alpn_protocol_list_length;
} tsi_ssl_server_handshaker_factory;
typedef struct {
@ -95,8 +95,8 @@ typedef struct {
BIO* into_ssl;
BIO* from_ssl;
unsigned char* buffer;
uint32_t buffer_size;
uint32_t buffer_offset;
size_t buffer_size;
size_t buffer_offset;
} tsi_ssl_frame_protector;
/* --- Library Initialization. ---*/
@ -159,7 +159,7 @@ static void ssl_info_callback(const SSL* ssl, int where, int ret) {
/* Gets the subject CN from an X509 cert. */
static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8,
uint32_t* utf8_size) {
size_t* utf8_size) {
int common_name_index = -1;
X509_NAME_ENTRY* common_name_entry = NULL;
ASN1_STRING* common_name_asn1 = NULL;
@ -200,7 +200,7 @@ static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8,
static tsi_result peer_property_from_x509_common_name(
X509* cert, tsi_peer_property* property) {
unsigned char* common_name;
uint32_t common_name_size;
size_t common_name_size;
tsi_result result =
ssl_get_x509_common_name(cert, &common_name, &common_name_size);
if (result != TSI_OK) return result;
@ -266,7 +266,7 @@ static tsi_result peer_property_from_x509_subject_alt_names(
static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
tsi_peer* peer) {
/* TODO(jboeuf): Maybe add more properties. */
uint32_t property_count = include_certificate_type ? 3 : 2;
size_t property_count = include_certificate_type ? 3 : 2;
tsi_result result = tsi_construct_peer(property_count, peer);
if (result != TSI_OK) return result;
do {
@ -299,7 +299,7 @@ static void log_ssl_error_stack(void) {
/* Performs an SSL_read and handle errors. */
static tsi_result do_ssl_read(SSL* ssl, unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size) {
size_t* unprotected_bytes_size) {
int read_from_ssl = SSL_read(ssl, unprotected_bytes, *unprotected_bytes_size);
if (read_from_ssl == 0) {
gpr_log(GPR_ERROR, "SSL_read returned 0 unexpectedly.");
@ -333,7 +333,7 @@ static tsi_result do_ssl_read(SSL* ssl, unsigned char* unprotected_bytes,
/* Performs an SSL_write and handle errors. */
static tsi_result do_ssl_write(SSL* ssl, unsigned char* unprotected_bytes,
uint32_t unprotected_bytes_size) {
size_t unprotected_bytes_size) {
int ssl_write_result =
SSL_write(ssl, unprotected_bytes, unprotected_bytes_size);
if (ssl_write_result < 0) {
@ -354,7 +354,7 @@ static tsi_result do_ssl_write(SSL* ssl, unsigned char* unprotected_bytes,
/* Loads an in-memory PEM certificate chain into the SSL context. */
static tsi_result ssl_ctx_use_certificate_chain(
SSL_CTX* context, const unsigned char* pem_cert_chain,
uint32_t pem_cert_chain_size) {
size_t pem_cert_chain_size) {
tsi_result result = TSI_OK;
X509* certificate = NULL;
BIO* pem = BIO_new_mem_buf((void*)pem_cert_chain, pem_cert_chain_size);
@ -395,7 +395,7 @@ static tsi_result ssl_ctx_use_certificate_chain(
/* Loads an in-memory PEM private key into the SSL context. */
static tsi_result ssl_ctx_use_private_key(SSL_CTX* context,
const unsigned char* pem_key,
uint32_t pem_key_size) {
size_t pem_key_size) {
tsi_result result = TSI_OK;
EVP_PKEY* private_key = NULL;
BIO* pem = BIO_new_mem_buf((void*)pem_key, pem_key_size);
@ -419,10 +419,10 @@ static tsi_result ssl_ctx_use_private_key(SSL_CTX* context,
/* Loads in-memory PEM verification certs into the SSL context and optionally
returns the verification cert names (root_names can be NULL). */
static tsi_result ssl_ctx_load_verification_certs(
SSL_CTX* context, const unsigned char* pem_roots, uint32_t pem_roots_size,
SSL_CTX* context, const unsigned char* pem_roots, size_t pem_roots_size,
STACK_OF(X509_NAME) * *root_names) {
tsi_result result = TSI_OK;
uint32_t num_roots = 0;
size_t num_roots = 0;
X509* root = NULL;
X509_NAME* root_name = NULL;
BIO* pem = BIO_new_mem_buf((void*)pem_roots, pem_roots_size);
@ -485,8 +485,8 @@ static tsi_result ssl_ctx_load_verification_certs(
cipher list and the ephemeral ECDH key. */
static tsi_result populate_ssl_context(
SSL_CTX* context, const unsigned char* pem_private_key,
uint32_t pem_private_key_size, const unsigned char* pem_certificate_chain,
uint32_t pem_certificate_chain_size, const char* cipher_list) {
size_t pem_private_key_size, const unsigned char* pem_certificate_chain,
size_t pem_certificate_chain_size, const char* cipher_list) {
tsi_result result = TSI_OK;
if (pem_certificate_chain != NULL) {
result = ssl_ctx_use_certificate_chain(context, pem_certificate_chain,
@ -522,7 +522,7 @@ static tsi_result populate_ssl_context(
/* Extracts the CN and the SANs from an X509 cert as a peer object. */
static tsi_result extract_x509_subject_names_from_pem_cert(
const unsigned char* pem_cert, uint32_t pem_cert_size, tsi_peer* peer) {
const unsigned char* pem_cert, size_t pem_cert_size, tsi_peer* peer) {
tsi_result result = TSI_OK;
X509* cert = NULL;
BIO* pem = BIO_new_mem_buf((void*)pem_cert, pem_cert_size);
@ -544,7 +544,7 @@ static tsi_result extract_x509_subject_names_from_pem_cert(
static tsi_result build_alpn_protocol_name_list(
const unsigned char** alpn_protocols,
const unsigned char* alpn_protocols_lengths, uint16_t num_alpn_protocols,
unsigned char** protocol_name_list, uint32_t* protocol_name_list_length) {
unsigned char** protocol_name_list, size_t* protocol_name_list_length) {
uint16_t i;
unsigned char* current;
*protocol_name_list = NULL;
@ -575,15 +575,15 @@ static tsi_result build_alpn_protocol_name_list(
static tsi_result ssl_protector_protect(
tsi_frame_protector* self, const unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size, unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size) {
size_t* unprotected_bytes_size, unsigned char* protected_output_frames,
size_t* protected_output_frames_size) {
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
int read_from_ssl;
uint32_t available;
size_t available;
tsi_result result = TSI_OK;
/* First see if we have some pending data in the SSL BIO. */
uint32_t pending_in_ssl = BIO_ctrl_pending(impl->from_ssl);
size_t pending_in_ssl = BIO_ctrl_pending(impl->from_ssl);
if (pending_in_ssl > 0) {
*unprotected_bytes_size = 0;
read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
@ -627,7 +627,7 @@ static tsi_result ssl_protector_protect(
static tsi_result ssl_protector_protect_flush(
tsi_frame_protector* self, unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size, uint32_t* still_pending_size) {
size_t* protected_output_frames_size, size_t* still_pending_size) {
tsi_result result = TSI_OK;
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
int read_from_ssl = 0;
@ -654,12 +654,12 @@ static tsi_result ssl_protector_protect_flush(
static tsi_result ssl_protector_unprotect(
tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
uint32_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size) {
size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size) {
tsi_result result = TSI_OK;
int written_into_ssl = 0;
uint32_t output_bytes_size = *unprotected_bytes_size;
uint32_t output_bytes_offset = 0;
size_t output_bytes_size = *unprotected_bytes_size;
size_t output_bytes_offset = 0;
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
/* First, try to read remaining data from ssl. */
@ -708,7 +708,7 @@ static const tsi_frame_protector_vtable frame_protector_vtable = {
/* --- tsi_handshaker methods implementation. ---*/
static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(
tsi_handshaker* self, unsigned char* bytes, uint32_t* bytes_size) {
tsi_handshaker* self, unsigned char* bytes, size_t* bytes_size) {
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
int bytes_read_from_ssl = 0;
if (bytes == NULL || bytes_size == NULL || *bytes_size == 0 ||
@ -725,7 +725,7 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(
return TSI_OK;
}
}
*bytes_size = (uint32_t)bytes_read_from_ssl;
*bytes_size = (size_t)bytes_read_from_ssl;
return BIO_ctrl_pending(impl->from_ssl) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
}
@ -739,7 +739,7 @@ static tsi_result ssl_handshaker_get_result(tsi_handshaker* self) {
}
static tsi_result ssl_handshaker_process_bytes_from_peer(
tsi_handshaker* self, const unsigned char* bytes, uint32_t* bytes_size) {
tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size) {
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
int bytes_written_into_ssl_size = 0;
if (bytes == NULL || bytes_size == 0 || *bytes_size > INT_MAX) {
@ -796,7 +796,7 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self,
}
SSL_get0_alpn_selected(impl->ssl, &alpn_selected, &alpn_selected_len);
if (alpn_selected != NULL) {
uint32_t i;
size_t i;
tsi_peer_property* new_properties =
calloc(1, sizeof(tsi_peer_property) * (peer->property_count + 1));
if (new_properties == NULL) return TSI_OUT_OF_RESOURCES;
@ -818,9 +818,9 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self,
}
static tsi_result ssl_handshaker_create_frame_protector(
tsi_handshaker* self, uint32_t* max_output_protected_frame_size,
tsi_handshaker* self, size_t* max_output_protected_frame_size,
tsi_frame_protector** protector) {
uint32_t actual_max_output_protected_frame_size =
size_t actual_max_output_protected_frame_size =
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND;
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
tsi_ssl_frame_protector* protector_impl =
@ -993,7 +993,7 @@ static void ssl_server_handshaker_factory_destroy(
tsi_ssl_handshaker_factory* self) {
tsi_ssl_server_handshaker_factory* impl =
(tsi_ssl_server_handshaker_factory*)self;
uint32_t i;
size_t i;
for (i = 0; i < impl->ssl_context_count; i++) {
if (impl->ssl_contexts[i] != NULL) {
SSL_CTX_free(impl->ssl_contexts[i]);
@ -1008,7 +1008,7 @@ static void ssl_server_handshaker_factory_destroy(
free(impl);
}
static int does_entry_match_name(const char* entry, uint32_t entry_length,
static int does_entry_match_name(const char* entry, size_t entry_length,
const char* name) {
const char* name_subdomain = NULL;
if (entry_length == 0) return 0;
@ -1035,7 +1035,7 @@ static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap,
void* arg) {
tsi_ssl_server_handshaker_factory* impl =
(tsi_ssl_server_handshaker_factory*)arg;
uint32_t i = 0;
size_t i = 0;
const char* servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
if (servername == NULL || strlen(servername) == 0) {
return SSL_TLSEXT_ERR_NOACK;
@ -1080,9 +1080,9 @@ static int server_handshaker_factory_alpn_callback(
/* --- tsi_ssl_handshaker_factory constructors. --- */
tsi_result tsi_create_ssl_client_handshaker_factory(
const unsigned char* pem_private_key, uint32_t pem_private_key_size,
const unsigned char* pem_cert_chain, uint32_t pem_cert_chain_size,
const unsigned char* pem_root_certs, uint32_t pem_root_certs_size,
const unsigned char* pem_private_key, size_t pem_private_key_size,
const unsigned char* pem_cert_chain, size_t pem_cert_chain_size,
const unsigned char* pem_root_certs, size_t pem_root_certs_size,
const char* cipher_list, const unsigned char** alpn_protocols,
const unsigned char* alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory** factory) {
@ -1115,7 +1115,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
if (num_alpn_protocols != 0) {
unsigned char* alpn_protocol_list = NULL;
uint32_t alpn_protocol_list_length = 0;
size_t alpn_protocol_list_length = 0;
int ssl_failed;
result = build_alpn_protocol_name_list(
alpn_protocols, alpn_protocols_lengths, num_alpn_protocols,
@ -1157,17 +1157,17 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
tsi_result tsi_create_ssl_server_handshaker_factory(
const unsigned char** pem_private_keys,
const uint32_t* pem_private_keys_sizes,
const size_t* pem_private_keys_sizes,
const unsigned char** pem_cert_chains,
const uint32_t* pem_cert_chains_sizes, uint32_t key_cert_pair_count,
const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count,
const unsigned char* pem_client_root_certs,
uint32_t pem_client_root_certs_size, const char* cipher_list,
size_t pem_client_root_certs_size, const char* cipher_list,
const unsigned char** alpn_protocols,
const unsigned char* alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory** factory) {
tsi_ssl_server_handshaker_factory* impl = NULL;
tsi_result result = TSI_OK;
uint32_t i = 0;
size_t i = 0;
gpr_once_init(&init_openssl_once, init_openssl);
@ -1255,7 +1255,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
/* --- tsi_ssl utils. --- */
int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) {
uint32_t i = 0;
size_t i = 0;
const tsi_peer_property* property = tsi_peer_get_property_by_name(
peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
if (property == NULL || property->type != TSI_PEER_PROPERTY_TYPE_STRING) {

@ -89,9 +89,9 @@ typedef struct tsi_ssl_handshaker_factory tsi_ssl_handshaker_factory;
- This method returns TSI_OK on success or TSI_INVALID_PARAMETER in the case
where a parameter is invalid. */
tsi_result tsi_create_ssl_client_handshaker_factory(
const unsigned char* pem_private_key, uint32_t pem_private_key_size,
const unsigned char* pem_cert_chain, uint32_t pem_cert_chain_size,
const unsigned char* pem_root_certs, uint32_t pem_root_certs_size,
const unsigned char* pem_private_key, size_t pem_private_key_size,
const unsigned char* pem_cert_chain, size_t pem_cert_chain_size,
const unsigned char* pem_root_certs, size_t pem_root_certs_size,
const char* cipher_suites, const unsigned char** alpn_protocols,
const unsigned char* alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory** factory);
@ -132,11 +132,11 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
where a parameter is invalid. */
tsi_result tsi_create_ssl_server_handshaker_factory(
const unsigned char** pem_private_keys,
const uint32_t* pem_private_keys_sizes,
const size_t* pem_private_keys_sizes,
const unsigned char** pem_cert_chains,
const uint32_t* pem_cert_chains_sizes, uint32_t key_cert_pair_count,
const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count,
const unsigned char* pem_client_root_certs,
uint32_t pem_client_root_certs_size, const char* cipher_suites,
size_t pem_client_root_certs_size, const char* cipher_suites,
const unsigned char** alpn_protocols,
const unsigned char* alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory** factory);

@ -40,7 +40,7 @@
char* tsi_strdup(const char* src) {
char* dst;
uint32_t len;
size_t len;
if (!src) return NULL;
len = strlen(src) + 1;
dst = malloc(len);
@ -90,9 +90,9 @@ const char* tsi_result_to_string(tsi_result result) {
tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
const unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size,
size_t* unprotected_bytes_size,
unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size) {
size_t* protected_output_frames_size) {
if (self == NULL || unprotected_bytes == NULL ||
unprotected_bytes_size == NULL || protected_output_frames == NULL ||
protected_output_frames_size == NULL) {
@ -105,7 +105,7 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
tsi_result tsi_frame_protector_protect_flush(
tsi_frame_protector* self, unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size, uint32_t* still_pending_size) {
size_t* protected_output_frames_size, size_t* still_pending_size) {
if (self == NULL || protected_output_frames == NULL ||
protected_output_frames == NULL || still_pending_size == NULL) {
return TSI_INVALID_ARGUMENT;
@ -117,8 +117,8 @@ tsi_result tsi_frame_protector_protect_flush(
tsi_result tsi_frame_protector_unprotect(
tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
uint32_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size) {
size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size) {
if (self == NULL || protected_frames_bytes == NULL ||
protected_frames_bytes_size == NULL || unprotected_bytes == NULL ||
unprotected_bytes_size == NULL) {
@ -140,7 +140,7 @@ void tsi_frame_protector_destroy(tsi_frame_protector* self) {
tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
unsigned char* bytes,
uint32_t* bytes_size) {
size_t* bytes_size) {
if (self == NULL) return TSI_INVALID_ARGUMENT;
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
return self->vtable->get_bytes_to_send_to_peer(self, bytes, bytes_size);
@ -148,7 +148,7 @@ tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker* self,
const unsigned char* bytes,
uint32_t* bytes_size) {
size_t* bytes_size) {
if (self == NULL) return TSI_INVALID_ARGUMENT;
if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
return self->vtable->process_bytes_from_peer(self, bytes, bytes_size);
@ -171,7 +171,7 @@ tsi_result tsi_handshaker_extract_peer(tsi_handshaker* self, tsi_peer* peer) {
}
tsi_result tsi_handshaker_create_frame_protector(
tsi_handshaker* self, uint32_t* max_protected_frame_size,
tsi_handshaker* self, size_t* max_protected_frame_size,
tsi_frame_protector** protector) {
tsi_result result;
if (self == NULL || protector == NULL) return TSI_INVALID_ARGUMENT;
@ -196,7 +196,7 @@ void tsi_handshaker_destroy(tsi_handshaker* self) {
const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* self,
const char* name) {
uint32_t i;
size_t i;
if (self == NULL) return NULL;
for (i = 0; i < self->property_count; i++) {
const tsi_peer_property* property = &self->properties[i];
@ -218,8 +218,8 @@ tsi_peer_property tsi_init_peer_property(void) {
}
static void tsi_peer_destroy_list_property(tsi_peer_property* children,
uint32_t child_count) {
uint32_t i;
size_t child_count) {
size_t i;
for (i = 0; i < child_count; i++) {
tsi_peer_property_destruct(&children[i]);
}
@ -292,7 +292,7 @@ tsi_result tsi_construct_real_peer_property(const char* name, double value,
}
tsi_result tsi_construct_allocated_string_peer_property(
const char* name, uint32_t value_length, tsi_peer_property* property) {
const char* name, size_t value_length, tsi_peer_property* property) {
*property = tsi_init_peer_property();
property->type = TSI_PEER_PROPERTY_TYPE_STRING;
if (name != NULL) {
@ -318,7 +318,7 @@ tsi_result tsi_construct_string_peer_property_from_cstring(
tsi_result tsi_construct_string_peer_property(const char* name,
const char* value,
uint32_t value_length,
size_t value_length,
tsi_peer_property* property) {
tsi_result result = tsi_construct_allocated_string_peer_property(
name, value_length, property);
@ -330,7 +330,7 @@ tsi_result tsi_construct_string_peer_property(const char* name,
}
tsi_result tsi_construct_list_peer_property(const char* name,
uint32_t child_count,
size_t child_count,
tsi_peer_property* property) {
*property = tsi_init_peer_property();
property->type = TSI_PEER_PROPERTY_TYPE_LIST;
@ -350,7 +350,7 @@ tsi_result tsi_construct_list_peer_property(const char* name,
return TSI_OK;
}
tsi_result tsi_construct_peer(uint32_t property_count, tsi_peer* peer) {
tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer) {
memset(peer, 0, sizeof(tsi_peer));
if (property_count > 0) {
peer->properties = calloc(property_count, sizeof(tsi_peer_property));

@ -45,18 +45,18 @@ extern "C" {
typedef struct {
tsi_result (*protect)(tsi_frame_protector* self,
const unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size,
size_t* unprotected_bytes_size,
unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size);
size_t* protected_output_frames_size);
tsi_result (*protect_flush)(tsi_frame_protector* self,
unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size,
uint32_t* still_pending_size);
size_t* protected_output_frames_size,
size_t* still_pending_size);
tsi_result (*unprotect)(tsi_frame_protector* self,
const unsigned char* protected_frames_bytes,
uint32_t* protected_frames_bytes_size,
size_t* protected_frames_bytes_size,
unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size);
size_t* unprotected_bytes_size);
void (*destroy)(tsi_frame_protector* self);
} tsi_frame_protector_vtable;
@ -69,14 +69,14 @@ struct tsi_frame_protector {
typedef struct {
tsi_result (*get_bytes_to_send_to_peer)(tsi_handshaker* self,
unsigned char* bytes,
uint32_t* bytes_size);
size_t* bytes_size);
tsi_result (*process_bytes_from_peer)(tsi_handshaker* self,
const unsigned char* bytes,
uint32_t* bytes_size);
size_t* bytes_size);
tsi_result (*get_result)(tsi_handshaker* self);
tsi_result (*extract_peer)(tsi_handshaker* self, tsi_peer* peer);
tsi_result (*create_frame_protector)(tsi_handshaker* self,
uint32_t* max_protected_frame_size,
size_t* max_protected_frame_size,
tsi_frame_protector** protector);
void (*destroy)(tsi_handshaker* self);
} tsi_handshaker_vtable;
@ -87,7 +87,7 @@ struct tsi_handshaker {
};
/* Peer and property construction/destruction functions. */
tsi_result tsi_construct_peer(uint32_t property_count, tsi_peer* peer);
tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer);
tsi_peer_property tsi_init_peer_property(void);
void tsi_peer_property_destruct(tsi_peer_property* property);
tsi_result tsi_construct_signed_integer_peer_property(
@ -98,14 +98,14 @@ tsi_result tsi_construct_real_peer_property(const char* name, double value,
tsi_peer_property* property);
tsi_result tsi_construct_string_peer_property(const char* name,
const char* value,
uint32_t value_length,
size_t value_length,
tsi_peer_property* property);
tsi_result tsi_construct_allocated_string_peer_property(
const char* name, uint32_t value_length, tsi_peer_property* property);
const char* name, size_t value_length, tsi_peer_property* property);
tsi_result tsi_construct_string_peer_property_from_cstring(
const char* name, const char* value, tsi_peer_property* property);
tsi_result tsi_construct_list_peer_property(const char* name,
uint32_t child_count,
size_t child_count,
tsi_peer_property* property);
/* Utils. */

@ -35,6 +35,7 @@
#define __TRANSPORT_SECURITY_INTERFACE_H_
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
@ -89,11 +90,11 @@ typedef struct tsi_frame_protector tsi_frame_protector;
------------------------------------------------------------------------
unsigned char protected_buffer[4096];
uint32_t protected_buffer_size = sizeof(protected_buffer);
size_t protected_buffer_size = sizeof(protected_buffer);
tsi_result result = TSI_OK;
while (message_size > 0) {
uint32_t protected_buffer_size_to_send = protected_buffer_size;
uint32_t processed_message_size = message_size;
size_t protected_buffer_size_to_send = protected_buffer_size;
size_t processed_message_size = message_size;
result = tsi_frame_protector_protect(protector,
message_bytes,
&processed_message_size,
@ -106,7 +107,7 @@ typedef struct tsi_frame_protector tsi_frame_protector;
// Don't forget to flush.
if (message_size == 0) {
uint32_t still_pending_size;
size_t still_pending_size;
do {
protected_buffer_size_to_send = protected_buffer_size;
result = tsi_frame_protector_protect_flush(
@ -122,9 +123,9 @@ typedef struct tsi_frame_protector tsi_frame_protector;
------------------------------------------------------------------------ */
tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
const unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size,
size_t* unprotected_bytes_size,
unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size);
size_t* protected_output_frames_size);
/* Indicates that we need to flush the bytes buffered in the protector and get
the resulting frame.
@ -136,7 +137,7 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
that still need to be flushed from the protector.*/
tsi_result tsi_frame_protector_protect_flush(
tsi_frame_protector* self, unsigned char* protected_output_frames,
uint32_t* protected_output_frames_size, uint32_t* still_pending_size);
size_t* protected_output_frames_size, size_t* still_pending_size);
/* Outputs unprotected bytes.
- protected_frames_bytes is an input only parameter and points to the
@ -160,8 +161,8 @@ tsi_result tsi_frame_protector_protect_flush(
protected_frames_size will be set to 0. */
tsi_result tsi_frame_protector_unprotect(
tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
uint32_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
uint32_t* unprotected_bytes_size);
size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size);
/* Destroys the tsi_frame_protector object. */
void tsi_frame_protector_destroy(tsi_frame_protector* self);
@ -194,18 +195,18 @@ typedef struct tsi_peer_property {
double real;
struct {
char* data;
uint32_t length;
size_t length;
} string;
struct {
struct tsi_peer_property* children;
uint32_t child_count;
size_t child_count;
} list;
} value;
} tsi_peer_property;
typedef struct {
tsi_peer_property* properties;
uint32_t property_count;
size_t property_count;
} tsi_peer;
/* Gets the first property with the specified name. Iteration over the
@ -227,12 +228,12 @@ void tsi_peer_destruct(tsi_peer* self);
------------------------------------------------------------------------
tsi_result result = TSI_OK;
unsigned char buf[4096];
uint32_t buf_offset;
uint32_t buf_size;
size_t buf_offset;
size_t buf_size;
while (1) {
// See if we need to send some bytes to the peer.
do {
uint32_t buf_size_to_send = sizeof(buf);
size_t buf_size_to_send = sizeof(buf);
result = tsi_handshaker_get_bytes_to_send_to_peer(handshaker, buf,
&buf_size_to_send);
if (buf_size_to_send > 0) send_bytes_to_peer(buf, buf_size_to_send);
@ -250,7 +251,7 @@ void tsi_peer_destruct(tsi_peer* self);
// Process the bytes from the peer. We have to be careful as these bytes
// may contain non-handshake data (protected data). If this is the case,
// we will exit from the loop with buf_size > 0.
uint32_t consumed_by_handshaker = buf_size;
size_t consumed_by_handshaker = buf_size;
result = tsi_handshaker_process_bytes_from_peer(
handshaker, buf, &consumed_by_handshaker);
buf_size -= consumed_by_handshaker;
@ -300,7 +301,7 @@ typedef struct tsi_handshaker tsi_handshaker;
error in the handshake, another specific error code is returned. */
tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
unsigned char* bytes,
uint32_t* bytes_size);
size_t* bytes_size);
/* Processes bytes received from the peer.
- bytes is the buffer containing the data.
@ -313,7 +314,7 @@ tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
returned. */
tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker* self,
const unsigned char* bytes,
uint32_t* bytes_size);
size_t* bytes_size);
/* Gets the result of the handshaker.
Returns TSI_OK if the hanshake completed successfully and there has been no
@ -349,7 +350,7 @@ tsi_result tsi_handshaker_extract_peer(tsi_handshaker* self, tsi_peer* peer);
the handshaker is not in a fatal error state.
The caller is responsible for destroying the protector. */
tsi_result tsi_handshaker_create_frame_protector(
tsi_handshaker* self, uint32_t* max_output_protected_frame_size,
tsi_handshaker* self, size_t* max_output_protected_frame_size,
tsi_frame_protector** protector);
/* This method releases the tsi_handshaker object. After this method is called,

@ -39,30 +39,48 @@ CPPFLAGS_dbg = -O0
LDFLAGS_dbg =
DEFINES_dbg = _DEBUG DEBUG
VALID_CONFIG_valgrind = 1
REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
CC_valgrind = gcc
CXX_valgrind = g++
LD_valgrind = gcc
LDXX_valgrind = g++
CPPFLAGS_valgrind = -O0
OPENSSL_CFLAGS_valgrind = -DPURIFY
LDFLAGS_valgrind =
DEFINES_valgrind = _DEBUG DEBUG
VALID_CONFIG_tsan = 1
REQUIRE_CUSTOM_LIBRARIES_tsan = 1
CC_tsan = clang
CXX_tsan = clang++
LD_tsan = clang
LDXX_tsan = clang++
CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
OPENSSL_CONFIG_tsan = no-asm
LDFLAGS_tsan = -fsanitize=thread
DEFINES_tsan = NDEBUG
VALID_CONFIG_asan = 1
REQUIRE_CUSTOM_LIBRARIES_asan = 1
CC_asan = clang
CXX_asan = clang++
LD_asan = clang
LDXX_asan = clang++
CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
OPENSSL_CONFIG_asan = no-asm
LDFLAGS_asan = -fsanitize=address
DEFINES_asan = NDEBUG
VALID_CONFIG_msan = 1
REQUIRE_CUSTOM_LIBRARIES_msan = 1
CC_msan = clang
CXX_msan = clang++
LD_msan = clang
LDXX_msan = clang++
CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer
OPENSSL_CFLAGS_msan = -DPURIFY
OPENSSL_CONFIG_msan = no-asm
LDFLAGS_msan = -fsanitize=memory
DEFINES_msan = NDEBUG
@ -172,8 +190,14 @@ endif
OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
else
# override system libraries if the config requires a custom compiled library
HAS_SYSTEM_OPENSSL_ALPN = false
HAS_SYSTEM_ZLIB = false
endif
ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
HAS_EMBEDDED_OPENSSL_ALPN = false
@ -189,7 +213,7 @@ endif
ifeq ($(HAS_SYSTEM_ZLIB),false)
ifeq ($(HAS_EMBEDDED_ZLIB),true)
ZLIB_DEP = third_party/zlib/libz.a
ZLIB_DEP = libs/$(CONFIG)/zlib/libz.a
CPPFLAGS += -Ithird_party/zlib
LDFLAGS += -Lthird_party/zlib
else
@ -199,10 +223,10 @@ endif
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
OPENSSL_DEP = third_party/openssl/libssl.a
OPENSSL_MERGE_LIBS += third_party/openssl/libssl.a third_party/openssl/libcrypto.a
OPENSSL_DEP = libs/$(CONFIG)/openssl/libssl.a
OPENSSL_MERGE_LIBS += libs/$(CONFIG)/openssl/libssl.a libs/$(CONFIG)/openssl/libcrypto.a
CPPFLAGS += -Ithird_party/openssl/include
LDFLAGS += -Lthird_party/openssl
LDFLAGS += -Llibs/$(CONFIG)/openssl
LIBS_SECURE = dl
else
NO_SECURE = true
@ -213,16 +237,19 @@ endif
LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
ifneq ($(DEP_MISSING),)
NO_DEPS = true
endif
ifneq ($(MAKECMDGOALS),clean)
ifeq ($(MAKECMDGOALS),clean)
NO_DEPS = true
endif
.SECONDARY = %.pb.h %.pb.cc
PROTOC_PLUGINS=\
% for tgt in targets:
% if tgt.build == 'protoc':
bins/$(CONFIG)/${tgt.name}\
% endif
% endfor
ifeq ($(DEP_MISSING),)
all: static shared\
% for tgt in targets:
@ -290,17 +317,25 @@ run_dep_checks:
$(OPENSSL_ALPN_CHECK_CMD) || true
$(ZLIB_CHECK_CMD) || true
third_party/zlib/libz.a:
(cd third_party/zlib ; CFLAGS="-fPIC -fvisibility=hidden" ./configure --static)
$(MAKE) -C third_party/zlib
third_party/openssl/libssl.a:
(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden" ./config)
$(MAKE) -C third_party/openssl build_crypto build_ssl
libs/$(CONFIG)/zlib/libz.a:
$(E) "[MAKE] Building zlib"
$(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="-fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static)
$(Q)$(MAKE) -C third_party/zlib clean
$(Q)$(MAKE) -C third_party/zlib
$(Q)mkdir -p libs/$(CONFIG)/zlib
$(Q)cp third_party/zlib/libz.a libs/$(CONFIG)/zlib
libs/$(CONFIG)/openssl/libssl.a:
$(E) "[MAKE] Building openssl"
$(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config $(OPENSSL_CONFIG_$(CONFIG)))
$(Q)$(MAKE) -C third_party/openssl clean
$(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
$(Q)mkdir -p libs/$(CONFIG)/openssl
$(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a libs/$(CONFIG)/openssl
static: static_c static_cxx
static_c: dep_c\
static_c: \
% for lib in libs:
% if lib.build == 'all' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -308,7 +343,7 @@ static_c: dep_c\
% endfor
static_cxx: dep_cxx\
static_cxx: \
% for lib in libs:
% if lib.build == 'all' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -318,7 +353,7 @@ static_cxx: dep_cxx\
shared: shared_c shared_cxx
shared_c: dep_c\
shared_c: \
% for lib in libs:
% if lib.build == 'all' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
@ -326,7 +361,7 @@ shared_c: dep_c\
% endfor
shared_cxx: dep_cxx\
shared_cxx: \
% for lib in libs:
% if lib.build == 'all' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
@ -336,7 +371,7 @@ shared_cxx: dep_cxx\
privatelibs: privatelibs_c privatelibs_cxx
privatelibs_c: dep_c\
privatelibs_c: \
% for lib in libs:
% if lib.build == 'private' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -344,7 +379,7 @@ privatelibs_c: dep_c\
% endfor
privatelibs_cxx: dep_cxx\
privatelibs_cxx: \
% for lib in libs:
% if lib.build == 'private' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -354,7 +389,7 @@ privatelibs_cxx: dep_cxx\
buildtests: buildtests_c buildtests_cxx
buildtests_c: bins_dep_c privatelibs_c\
buildtests_c: privatelibs_c\
% for tgt in targets:
% if tgt.build == 'test' and not tgt.get('c++', False):
bins/$(CONFIG)/${tgt.name}\
@ -362,7 +397,7 @@ buildtests_c: bins_dep_c privatelibs_c\
% endfor
buildtests_cxx: bins_dep_cxx privatelibs_cxx\
buildtests_cxx: privatelibs_cxx\
% for tgt in targets:
% if tgt.build == 'test' and tgt.get('c++', False):
bins/$(CONFIG)/${tgt.name}\
@ -398,14 +433,6 @@ tools: privatelibs\
% endfor
protoc_plugins:\
% for tgt in targets:
% if tgt.build == 'protoc':
bins/$(CONFIG)/${tgt.name}\
% endif
% endfor
buildbenchmarks: privatelibs\
% for tgt in targets:
% if tgt.build == 'benchmark':
@ -463,79 +490,32 @@ strip-shared_cxx: shared_cxx
% endfor
% for p in protos:
deps/$(CONFIG)/gens/${p}.pb.dep:
$(Q) mkdir -p `dirname $@`
$(Q) touch $@
gens/${p}.pb.cc: ${p}.proto protoc_plugins
gens/${p}.pb.cc: ${p}.proto $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) --cpp_out=gens --grpc_out=gens --plugin=protoc-gen-grpc=bins/$(CONFIG)/cpp_plugin $<
% endfor
deps/$(CONFIG)/%.dep : %.c
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
deps/$(CONFIG)/%.dep : %.cc
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
objs/$(CONFIG)/%.o : %.c
$(E) "[C] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/%.o : gens/%.pb.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
$(E) "[HOSTCXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -c -o $@ $<
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/%.o : %.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
dep: dep_c dep_cxx
dep_c:\
% for lib in libs:
% if not lib.get('c++', False):
deps_lib${lib.name}\
% endif
% endfor
bins_dep_c:\
% for tgt in targets:
% if not tgt.get('c++', False):
deps_${tgt.name}\
% endif
% endfor
dep_cxx:\
% for lib in libs:
% if lib.get('c++', False):
deps_lib${lib.name}\
% endif
% endfor
bins_dep_cxx:\
% for tgt in targets:
% if tgt.get('c++', False):
deps_${tgt.name}\
% endif
% endfor
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
install: install_c install_cxx
@ -624,15 +604,8 @@ ifneq ($(SYSTEM),Darwin)
endif
endif
clean:\
% for lib in libs:
clean_lib${lib.name}\
% endfor
% for tgt in targets:
clean_${tgt.name}\
% endfor
$(Q) $(RM) -r deps objs libs bins gens
clean:
$(Q) $(RM) -rf objs libs bins gens
# The various libraries
@ -671,7 +644,6 @@ PUBLIC_HEADERS_C += \\
% endif
LIB${lib.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
LIB${lib.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(LIB${lib.name.upper()}_SRC))))
% if lib.get('secure', True):
ifeq ($(NO_SECURE),true)
@ -688,9 +660,15 @@ endif
else
libs/$(CONFIG)/lib${lib.name}.a: $(OPENSSL_DEP) $(LIB${lib.name.upper()}_OBJS)
ifneq ($(OPENSSL_DEP),)
% for src in lib.src:
${src}: $(OPENSSL_DEP)
% endfor
endif
libs/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(LIB${lib.name.upper()}_OBJS)
% else:
libs/$(CONFIG)/lib${lib.name}.a: $(LIB${lib.name.upper()}_OBJS)
libs/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(LIB${lib.name.upper()}_OBJS)
% endif
$(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@`
@ -719,12 +697,12 @@ libs/$(CONFIG)/lib${lib.name}.a: $(LIB${lib.name.upper()}_OBJS)
common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
libs = ''
lib_deps = ''
lib_deps = ' $(ZLIB_DEP)'
mingw_libs = ''
mingw_lib_deps = ''
mingw_lib_deps = ' $(ZLIB_DEP)'
for dep in lib.get('deps', []):
libs = libs + ' -l' + dep
lib_deps = lib_deps + 'libs/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
lib_deps = lib_deps + ' libs/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
mingw_libs = mingw_libs + ' -l' + dep + '-imp'
mingw_lib_deps = mingw_lib_deps + 'libs/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
@ -732,7 +710,6 @@ libs/$(CONFIG)/lib${lib.name}.a: $(LIB${lib.name.upper()}_OBJS)
common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
lib_deps = lib_deps + ' $(OPENSSL_DEP)'
mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
%>
% if lib.build == "all":
@ -759,13 +736,11 @@ endif
endif
% endif
deps_lib${lib.name}: $(LIB${lib.name.upper()}_DEPS)
% if lib.get('secure', True):
ifneq ($(NO_SECURE),true)
% endif
ifneq ($(NO_DEPS),true)
-include $(LIB${lib.name.upper()}_DEPS)
-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
endif
% if lib.get('secure', True):
endif
@ -782,13 +757,6 @@ objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% endif
% endfor
clean_lib${lib.name}:
$(E) "[CLEAN] Cleaning lib${lib.name} files"
$(Q) $(RM) $(LIB${lib.name.upper()}_OBJS)
$(Q) $(RM) $(LIB${lib.name.upper()}_DEPS)
$(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.a
$(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
</%def>
<%def name="maketarget(tgt)">
@ -800,7 +768,6 @@ ${tgt.name.upper()}_SRC = \\
% endfor
${tgt.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
${tgt.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(${tgt.name.upper()}_SRC))))
% if tgt.get('secure', True):
ifeq ($(NO_SECURE),true)
@ -867,23 +834,17 @@ objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% endfor
deps_${tgt.name}: $(${tgt.name.upper()}_DEPS)
deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
% if tgt.get('secure', True):
ifneq ($(NO_SECURE),true)
% endif
ifneq ($(NO_DEPS),true)
-include $(${tgt.name.upper()}_DEPS)
-include $(${tgt.name.upper()}_OBJS:.o=.dep)
endif
% if tgt.get('secure', True):
endif
% endif
clean_${tgt.name}:
$(E) "[CLEAN] Cleaning ${tgt.name} files"
$(Q) $(RM) $(${tgt.name.upper()}_OBJS)
$(Q) $(RM) $(${tgt.name.upper()}_DEPS)
$(Q) $(RM) bins/$(CONFIG)/${tgt.name}
</%def>
.PHONY: all strip tools \
@ -897,12 +858,6 @@ install-static install-static_c install-static_cxx \
strip strip-shared strip-static \
strip_c strip-shared_c strip-static_c \
strip_cxx strip-shared_cxx strip-static_cxx \
clean \
dep_c dep_cxx bins_dep_c bins_dep_cxx\
% for lib in libs:
deps_lib${lib.name} clean_lib${lib.name}\
% endfor
% for tgt in targets:
deps_${tgt.name} clean_${tgt.name}\
% endfor
dep_c dep_cxx bins_dep_c bins_dep_cxx \
clean

@ -76,7 +76,7 @@ static void channel_func(grpc_channel_element *elem,
++*(int *)(elem->channel_data);
}
static void test_create_channel_stack() {
static void test_create_channel_stack(void) {
const grpc_channel_filter filter = {
call_func, channel_func,

@ -145,7 +145,7 @@ static gpr_slice create_test_value(test_value id) {
return gpr_slice_from_copied_string("bad value");
}
static void test_bad_data() {
static void test_bad_data(void) {
gpr_slice_buffer input;
gpr_slice_buffer output;
int i;

@ -56,7 +56,7 @@ typedef struct {
gpr_intmax bytes_read;
} call_state;
static void request_call() {
static void request_call(void) {
call_state *tag = gpr_malloc(sizeof(*tag));
gpr_ref_init(&tag->pending_ops, 2);
tag->bytes_read = 0;
@ -124,7 +124,9 @@ int main(int argc, char **argv) {
case GRPC_SERVER_RPC_NEW:
if (ev->call != NULL) {
/* initial ops are already started in request_call */
grpc_call_accept(ev->call, cq, s, GRPC_WRITE_BUFFER_HINT);
grpc_call_server_accept(ev->call, cq, s);
grpc_call_server_end_initial_metadata(ev->call,
GRPC_WRITE_BUFFER_HINT);
GPR_ASSERT(grpc_call_start_read(ev->call, s) == GRPC_CALL_OK);
request_call();
} else {

@ -131,7 +131,8 @@ void test_connect(const char *server_host, const char *client_host, int port,
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -72,7 +72,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -133,7 +133,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -72,7 +72,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -133,7 +133,8 @@ static void test_cancel_after_accept_and_writes_closed(
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -72,7 +72,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -68,7 +68,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -70,7 +70,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -122,7 +122,8 @@ static void test_body(grpc_end2end_test_fixture f) {
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -52,7 +52,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -115,7 +115,9 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f->server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_accept(s, f->server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -128,7 +128,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -100,7 +100,7 @@ static void end_test(grpc_end2end_test_fixture *f) {
grpc_completion_queue_destroy(f->client_cq);
}
static gpr_slice large_slice() {
static gpr_slice large_slice(void) {
gpr_slice slice = gpr_slice_malloc(1000000);
memset(GPR_SLICE_START_PTR(slice), 0xab, GPR_SLICE_LENGTH(slice));
return slice;
@ -143,7 +143,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
deadline, NULL);
cq_verify(v_server);
grpc_call_accept(s, f.server_cq, tag(102), 0);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -126,7 +126,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
@ -216,7 +217,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
"test.google.com", deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s1, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_accept(s1, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s1, 0));
cq_expect_client_metadata_read(v_client, tag(live_call + 1), NULL);
cq_verify(v_client);
@ -246,7 +249,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
"test.google.com", deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s2, f.server_cq, tag(202), 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_accept(s2, f.server_cq, tag(202)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s2, 0));
cq_expect_client_metadata_read(v_client, tag(live_call + 1), NULL);
cq_verify(v_client);

@ -62,7 +62,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -130,7 +130,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "test.google.com",
deadline, NULL);
cq_verify(v_server);
grpc_call_accept(s, f.server_cq, tag(102), 0);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -141,7 +141,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
deadline, NULL);
cq_verify(v_server);
grpc_call_accept(s, f.server_cq, tag(102), 0);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;

@ -52,7 +52,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -124,7 +124,9 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f->server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_accept(s, f->server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -126,7 +126,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);
@ -173,7 +174,8 @@ static void simple_request_body2(grpc_end2end_test_fixture f) {
deadline, NULL);
cq_verify(v_server);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(s, f.server_cq, tag(102), 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_write_status(
s, GRPC_STATUS_UNIMPLEMENTED, "xyz", tag(5)));

@ -56,7 +56,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
/* Drain pending events on a completion queue until it's ready to destroy.
Does some post-processing to safely release memory on some of the events. */
@ -105,7 +105,7 @@ static void drain_cq(int client, grpc_completion_queue *cq) {
}
/* Kick off a new request - assumes g_mu taken */
static void start_request() {
static void start_request(void) {
grpc_call *call = grpc_channel_create_call(
g_fixture.client, "/Foo", "test.google.com", g_test_end_time);
g_active_requests++;
@ -180,7 +180,7 @@ static void client_thread(void *p) {
/* Request a new server call. We tag them with a ref-count that starts at two,
and decrements after each of: a read completes and a write completes.
When it drops to zero, we write status */
static void request_server_call() {
static void request_server_call(void) {
gpr_refcount *rc = gpr_malloc(sizeof(gpr_refcount));
gpr_ref_init(rc, 2);
grpc_server_request_call(g_fixture.server, rc);
@ -218,9 +218,11 @@ static void server_thread(void *p) {
break;
case GRPC_SERVER_RPC_NEW:
if (ev->call) {
GPR_ASSERT(GRPC_CALL_OK == grpc_call_accept(ev->call,
g_fixture.server_cq,
ev->tag, 0));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_accept(ev->call, g_fixture.server_cq,
ev->tag));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_server_end_initial_metadata(ev->call, 0));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_read(ev->call, ev->tag));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_write(ev->call, buf, ev->tag, 0));

@ -64,7 +64,7 @@ static gpr_timespec n_seconds_time(int n) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n));
}
static gpr_timespec five_seconds_time() { return n_seconds_time(5); }
static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
static void drain_cq(grpc_completion_queue *cq) {
grpc_event *ev;
@ -145,7 +145,8 @@ static void test_writes_done_hangs_with_pending_read(
deadline, NULL);
cq_verify(v_server);
grpc_call_accept(s, f.server_cq, tag(102), 0);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept(s, f.server_cq, tag(102)));
GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata(s, 0));
cq_expect_client_metadata_read(v_client, tag(2), NULL);
cq_verify(v_client);

@ -50,9 +50,9 @@ static grpc_channel *channel;
static grpc_completion_queue *cq;
static grpc_call *call;
static void init_ping_pong_request() {}
static void init_ping_pong_request(void) {}
static void step_ping_pong_request() {
static void step_ping_pong_request(void) {
call = grpc_channel_create_call(channel, "/Reflector/reflectUnary",
"localhost", gpr_inf_future);
GPR_ASSERT(grpc_call_start_invoke(call, cq, (void *)1, (void *)1, (void *)1,
@ -71,7 +71,7 @@ static void step_ping_pong_request() {
call = NULL;
}
static void init_ping_pong_stream() {
static void init_ping_pong_stream(void) {
call = grpc_channel_create_call(channel, "/Reflector/reflectStream",
"localhost", gpr_inf_future);
GPR_ASSERT(grpc_call_start_invoke(call, cq, (void *)1, (void *)1, (void *)1,
@ -80,7 +80,7 @@ static void init_ping_pong_stream() {
grpc_event_finish(grpc_completion_queue_next(cq, gpr_inf_future));
}
static void step_ping_pong_stream() {
static void step_ping_pong_stream(void) {
GPR_ASSERT(grpc_call_start_write(call, the_buffer, (void *)1, 0) ==
GRPC_CALL_OK);
GPR_ASSERT(grpc_call_start_read(call, (void *)1) == GRPC_CALL_OK);
@ -88,7 +88,7 @@ static void step_ping_pong_stream() {
grpc_event_finish(grpc_completion_queue_next(cq, gpr_inf_future));
}
static double now() {
static double now(void) {
gpr_timespec tv = gpr_now();
return 1e9 * tv.tv_sec + tv.tv_nsec;
}

@ -57,7 +57,7 @@ typedef struct {
gpr_uint32 flags;
} call_state;
static void request_call() {
static void request_call(void) {
call_state *s = gpr_malloc(sizeof(call_state));
gpr_ref_init(&s->pending_ops, 2);
grpc_server_request_call(server, s);
@ -130,7 +130,8 @@ int main(int argc, char **argv) {
} else {
s->flags = GRPC_WRITE_BUFFER_HINT;
}
grpc_call_accept(ev->call, cq, s, s->flags);
grpc_call_server_accept(ev->call, cq, s);
grpc_call_server_end_initial_metadata(ev->call, s->flags);
GPR_ASSERT(grpc_call_start_read(ev->call, s) == GRPC_CALL_OK);
request_call();
} else {

@ -38,7 +38,7 @@
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
static void test_format_get_request() {
static void test_format_get_request(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
@ -63,7 +63,7 @@ static void test_format_get_request() {
gpr_slice_unref(slice);
}
static void test_format_post_request() {
static void test_format_post_request(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
@ -93,7 +93,7 @@ static void test_format_post_request() {
gpr_slice_unref(slice);
}
static void test_format_post_request_no_body() {
static void test_format_post_request_no_body(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
@ -118,7 +118,7 @@ static void test_format_post_request_no_body() {
gpr_slice_unref(slice);
}
static void test_format_post_request_content_type_override() {
static void test_format_post_request_content_type_override(void) {
grpc_httpcli_header hdrs[2];
grpc_httpcli_request req;
gpr_slice slice;

@ -40,7 +40,7 @@
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
static gpr_timespec random_deadline() {
static gpr_timespec random_deadline(void) {
gpr_timespec ts;
ts.tv_sec = rand();
ts.tv_nsec = rand();
@ -150,7 +150,7 @@ static void check_valid(grpc_alarm_heap *pq) {
}
}
static void test1() {
static void test1(void) {
grpc_alarm_heap pq;
const int num_test_elements = 200;
const int num_test_operations = 10000;
@ -206,7 +206,7 @@ static void test1() {
gpr_free(inpq);
}
static void shrink_test() {
static void shrink_test(void) {
grpc_alarm_heap pq;
int i;
int expected_size;

@ -44,13 +44,13 @@
static int cb_called[MAX_CB][2];
static int kicks;
void grpc_kick_poller() { ++kicks; }
void grpc_kick_poller(void) { ++kicks; }
static void cb(void *arg, int success) {
cb_called[(gpr_intptr)arg][success]++;
}
static void add_test() {
static void add_test(void) {
gpr_timespec start = gpr_now();
int i;
grpc_alarm alarms[20];
@ -108,7 +108,7 @@ static void add_test() {
}
/* Cleaning up a list with pending alarms. */
void destruction_test() {
void destruction_test(void) {
grpc_alarm alarms[5];
grpc_alarm_list_init(gpr_time_0);

@ -89,7 +89,7 @@ static void alarm_cb(void *arg /* alarm_arg */, int success) {
}
/* Test grpc_alarm add and cancel. */
static void test_grpc_alarm() {
static void test_grpc_alarm(void) {
grpc_alarm alarm;
grpc_alarm alarm_to_cancel;
/* Timeout on the alarm cond. var, so make big enough to absorb time

@ -349,7 +349,7 @@ static void client_wait_and_shutdown(client *cl) {
/* Test grpc_fd. Start an upload server and client, upload a stream of
bytes from the client to the server, and verify that the total number of
sent bytes is equal to the total number of received bytes. */
static void test_grpc_fd() {
static void test_grpc_fd(void) {
server sv;
client cl;
int port;
@ -403,7 +403,7 @@ static void second_read_callback(void *arg /* fd_change_data */, int success) {
Note that we have two different but almost identical callbacks above -- the
point is to have two different function pointers and two different data
pointers and make sure that changing both really works. */
static void test_grpc_fd_change() {
static void test_grpc_fd_change(void) {
grpc_fd *em_fd;
fd_change_data a, b;
int flags;

@ -37,7 +37,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
static gpr_timespec test_deadline() {
static gpr_timespec test_deadline(void) {
return gpr_time_add(gpr_now(), gpr_time_from_micros(100000000));
}
@ -53,35 +53,35 @@ static void must_fail(void* evp, grpc_resolved_addresses* p) {
gpr_event_set(evp, (void*)1);
}
static void test_localhost() {
static void test_localhost(void) {
gpr_event ev;
gpr_event_init(&ev);
grpc_resolve_address("localhost:1", NULL, must_succeed, &ev);
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
static void test_default_port() {
static void test_default_port(void) {
gpr_event ev;
gpr_event_init(&ev);
grpc_resolve_address("localhost", "1", must_succeed, &ev);
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
static void test_missing_default_port() {
static void test_missing_default_port(void) {
gpr_event ev;
gpr_event_init(&ev);
grpc_resolve_address("localhost", NULL, must_fail, &ev);
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
static void test_ipv6_with_port() {
static void test_ipv6_with_port(void) {
gpr_event ev;
gpr_event_init(&ev);
grpc_resolve_address("[2001:db8::1]:1", NULL, must_succeed, &ev);
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
static void test_ipv6_without_port() {
static void test_ipv6_without_port(void) {
const char* const kCases[] = {
"2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]",
};
@ -94,7 +94,7 @@ static void test_ipv6_without_port() {
}
}
static void test_invalid_ip_addresses() {
static void test_invalid_ip_addresses(void) {
const char* const kCases[] = {
"293.283.1238.3:1", "[2001:db8::11111]:1",
};
@ -107,7 +107,7 @@ static void test_invalid_ip_addresses() {
}
}
static void test_unparseable_hostports() {
static void test_unparseable_hostports(void) {
const char* const kCases[] = {
"[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1",
};

@ -70,7 +70,7 @@ static const gpr_uint8 kIPv4[] = {192, 0, 2, 1};
static const gpr_uint8 kIPv6[] = {0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1};
static void test_sockaddr_is_v4mapped() {
static void test_sockaddr_is_v4mapped(void) {
struct sockaddr_in input4;
struct sockaddr_in6 input6;
struct sockaddr_in output4;
@ -101,7 +101,7 @@ static void test_sockaddr_is_v4mapped() {
!grpc_sockaddr_is_v4mapped((const struct sockaddr *)&input4, NULL));
}
static void test_sockaddr_to_v4mapped() {
static void test_sockaddr_to_v4mapped(void) {
struct sockaddr_in input4;
struct sockaddr_in6 input6;
struct sockaddr_in6 output6;
@ -129,7 +129,7 @@ static void test_sockaddr_to_v4mapped() {
!grpc_sockaddr_to_v4mapped((const struct sockaddr *)&input6, &output6));
}
static void test_sockaddr_is_wildcard() {
static void test_sockaddr_is_wildcard(void) {
struct sockaddr_in wild4;
struct sockaddr_in6 wild6;
struct sockaddr_in6 wild_mapped;
@ -187,7 +187,7 @@ static void expect_sockaddr_str(const char *expected, void *addr,
gpr_free(str);
}
static void test_sockaddr_to_string() {
static void test_sockaddr_to_string(void) {
struct sockaddr_in input4;
struct sockaddr_in6 input6;
struct sockaddr dummy;

@ -43,7 +43,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
static gpr_timespec test_deadline() {
static gpr_timespec test_deadline(void) {
return gpr_time_add(gpr_now(), gpr_time_from_seconds(10));
}
@ -59,7 +59,7 @@ static void must_fail(void *arg, grpc_endpoint *tcp) {
gpr_event_set(arg, (void *)1);
}
void test_succeeds() {
void test_succeeds(void) {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
int svr_fd;
@ -94,7 +94,7 @@ void test_succeeds() {
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
void test_fails() {
void test_fails(void) {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
gpr_event ev;
@ -112,7 +112,7 @@ void test_fails() {
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
void test_times_out() {
void test_times_out(void) {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
int svr_fd;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save