diff options
author | 2016-09-20 11:02:51 -0700 | |
---|---|---|
committer | 2016-09-20 11:02:51 -0700 | |
commit | 1edc77c7c6267fc85a37adc5f539060c93e97528 (patch) | |
tree | 64d60676be5e38f1cd3cf9b017bf0937c28a48d1 /src/core/lib/channel/channel_args.c | |
parent | f4a7ecf3b6d2b26f9baa33ce5cd219270095e955 (diff) | |
parent | a6a6fa4f12c5634d87d8b4e64fa50c3618586a7c (diff) |
Merge github.com:grpc/grpc into direct-calls
Diffstat (limited to 'src/core/lib/channel/channel_args.c')
-rw-r--r-- | src/core/lib/channel/channel_args.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/lib/channel/channel_args.c b/src/core/lib/channel/channel_args.c index 79ceeb66b3..3a56b1ff20 100644 --- a/src/core/lib/channel/channel_args.c +++ b/src/core/lib/channel/channel_args.c @@ -271,3 +271,21 @@ int grpc_channel_args_compare(const grpc_channel_args *a, } return 0; } + +int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) { + if (arg->type != GRPC_ARG_INTEGER) { + gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key); + return options.default_value; + } + if (arg->value.integer < options.min_value) { + gpr_log(GPR_ERROR, "%s ignored: it must be >= %d", arg->key, + options.min_value); + return options.default_value; + } + if (arg->value.integer > options.max_value) { + gpr_log(GPR_ERROR, "%s ignored: it must be <= %d", arg->key, + options.max_value); + return options.default_value; + } + return arg->value.integer; +} |