Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 1948244 | 2016-01-25 09:59:20 -0800 | [diff] [blame] | 3 | * Copyright 2015-2016, Google Inc. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 34 | #include "src/core/channel/channel_args.h" |
Craig Tiller | f40df23 | 2016-03-25 13:38:14 -0700 | [diff] [blame] | 35 | #include <grpc/grpc.h> |
Craig Tiller | 485d776 | 2015-01-23 12:54:05 -0800 | [diff] [blame] | 36 | #include "src/core/support/string.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 37 | |
Bogdan Drutu | 441499a | 2016-01-26 19:16:04 -0800 | [diff] [blame] | 38 | #include <grpc/census.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 39 | #include <grpc/support/alloc.h> |
Craig Tiller | 7e5a9cf | 2016-02-02 09:28:22 -0800 | [diff] [blame] | 40 | #include <grpc/support/log.h> |
Masood Malekghassemi | 701af60 | 2015-06-03 15:01:17 -0700 | [diff] [blame] | 41 | #include <grpc/support/string_util.h> |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 42 | #include <grpc/support/useful.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 43 | |
| 44 | #include <string.h> |
| 45 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 46 | static grpc_arg copy_arg(const grpc_arg *src) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 47 | grpc_arg dst; |
| 48 | dst.type = src->type; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 49 | dst.key = gpr_strdup(src->key); |
| 50 | switch (dst.type) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 51 | case GRPC_ARG_STRING: |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 52 | dst.value.string = gpr_strdup(src->value.string); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 53 | break; |
| 54 | case GRPC_ARG_INTEGER: |
| 55 | dst.value.integer = src->value.integer; |
| 56 | break; |
| 57 | case GRPC_ARG_POINTER: |
| 58 | dst.value.pointer = src->value.pointer; |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 59 | dst.value.pointer.p = |
| 60 | src->value.pointer.vtable->copy(src->value.pointer.p); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 61 | break; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 62 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 63 | return dst; |
| 64 | } |
| 65 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 66 | grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src, |
| 67 | const grpc_arg *to_add, |
| 68 | size_t num_to_add) { |
| 69 | grpc_channel_args *dst = gpr_malloc(sizeof(grpc_channel_args)); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 70 | size_t i; |
| 71 | size_t src_num_args = (src == NULL) ? 0 : src->num_args; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 72 | if (!src && !to_add) { |
| 73 | dst->num_args = 0; |
| 74 | dst->args = NULL; |
| 75 | return dst; |
| 76 | } |
Craig Tiller | d9a5088 | 2015-06-29 15:57:36 -0700 | [diff] [blame] | 77 | dst->num_args = src_num_args + num_to_add; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 78 | dst->args = gpr_malloc(sizeof(grpc_arg) * dst->num_args); |
| 79 | for (i = 0; i < src_num_args; i++) { |
| 80 | dst->args[i] = copy_arg(&src->args[i]); |
| 81 | } |
| 82 | for (i = 0; i < num_to_add; i++) { |
| 83 | dst->args[i + src_num_args] = copy_arg(&to_add[i]); |
| 84 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 85 | return dst; |
| 86 | } |
| 87 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 88 | grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src) { |
| 89 | return grpc_channel_args_copy_and_add(src, NULL, 0); |
Craig Tiller | d9a5088 | 2015-06-29 15:57:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 92 | grpc_channel_args *grpc_channel_args_merge(const grpc_channel_args *a, |
| 93 | const grpc_channel_args *b) { |
| 94 | return grpc_channel_args_copy_and_add(a, b->args, b->num_args); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 97 | static int cmp_arg(const grpc_arg *a, const grpc_arg *b) { |
Craig Tiller | 1948244 | 2016-01-25 09:59:20 -0800 | [diff] [blame] | 98 | int c = GPR_ICMP(a->type, b->type); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 99 | if (c != 0) return c; |
| 100 | c = strcmp(a->key, b->key); |
| 101 | if (c != 0) return c; |
| 102 | switch (a->type) { |
| 103 | case GRPC_ARG_STRING: |
Craig Tiller | 7e5a9cf | 2016-02-02 09:28:22 -0800 | [diff] [blame] | 104 | return strcmp(a->value.string, b->value.string); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 105 | case GRPC_ARG_INTEGER: |
Craig Tiller | 7e5a9cf | 2016-02-02 09:28:22 -0800 | [diff] [blame] | 106 | return GPR_ICMP(a->value.integer, b->value.integer); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 107 | case GRPC_ARG_POINTER: |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 108 | c = GPR_ICMP(a->value.pointer.p, b->value.pointer.p); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 109 | if (c != 0) { |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 110 | c = GPR_ICMP(a->value.pointer.vtable, b->value.pointer.vtable); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 111 | if (c == 0) { |
| 112 | c = a->value.pointer.vtable->cmp(a->value.pointer.p, |
| 113 | b->value.pointer.p); |
| 114 | } |
| 115 | } |
Craig Tiller | 7e5a9cf | 2016-02-02 09:28:22 -0800 | [diff] [blame] | 116 | return c; |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 117 | } |
Craig Tiller | 7e5a9cf | 2016-02-02 09:28:22 -0800 | [diff] [blame] | 118 | GPR_UNREACHABLE_CODE(return 0); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 119 | } |
| 120 | |
Craig Tiller | 24e274b | 2016-02-11 08:54:49 -0800 | [diff] [blame] | 121 | /* stabilizing comparison function: since channel_args ordering matters for |
| 122 | * keys with the same name, we need to preserve that ordering */ |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 123 | static int cmp_key_stable(const void *ap, const void *bp) { |
| 124 | const grpc_arg *const *a = ap; |
| 125 | const grpc_arg *const *b = bp; |
| 126 | int c = strcmp((*a)->key, (*b)->key); |
| 127 | if (c == 0) c = GPR_ICMP(*a, *b); |
| 128 | return c; |
| 129 | } |
| 130 | |
| 131 | grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) { |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 132 | grpc_arg **args = gpr_malloc(sizeof(grpc_arg *) * a->num_args); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 133 | for (size_t i = 0; i < a->num_args; i++) { |
| 134 | args[i] = &a->args[i]; |
| 135 | } |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 136 | qsort(args, a->num_args, sizeof(grpc_arg *), cmp_key_stable); |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 137 | |
| 138 | grpc_channel_args *b = gpr_malloc(sizeof(grpc_channel_args)); |
| 139 | b->num_args = a->num_args; |
| 140 | b->args = gpr_malloc(sizeof(grpc_arg) * b->num_args); |
| 141 | for (size_t i = 0; i < a->num_args; i++) { |
| 142 | b->args[i] = copy_arg(args[i]); |
| 143 | } |
| 144 | |
| 145 | gpr_free(args); |
| 146 | return b; |
| 147 | } |
| 148 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 149 | void grpc_channel_args_destroy(grpc_channel_args *a) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 150 | size_t i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 151 | for (i = 0; i < a->num_args; i++) { |
| 152 | switch (a->args[i].type) { |
| 153 | case GRPC_ARG_STRING: |
| 154 | gpr_free(a->args[i].value.string); |
| 155 | break; |
| 156 | case GRPC_ARG_INTEGER: |
| 157 | break; |
| 158 | case GRPC_ARG_POINTER: |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 159 | a->args[i].value.pointer.vtable->destroy(a->args[i].value.pointer.p); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 160 | break; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 161 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 162 | gpr_free(a->args[i].key); |
| 163 | } |
| 164 | gpr_free(a->args); |
| 165 | gpr_free(a); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 168 | int grpc_channel_args_is_census_enabled(const grpc_channel_args *a) { |
David Garcia Quintas | 20afd46 | 2015-07-06 23:01:39 -0700 | [diff] [blame] | 169 | size_t i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 170 | if (a == NULL) return 0; |
| 171 | for (i = 0; i < a->num_args; i++) { |
| 172 | if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) { |
Bogdan Drutu | 441499a | 2016-01-26 19:16:04 -0800 | [diff] [blame] | 173 | return a->args[i].value.integer != 0 && census_enabled(); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 174 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 175 | } |
Bogdan Drutu | 441499a | 2016-01-26 19:16:04 -0800 | [diff] [blame] | 176 | return census_enabled(); |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 177 | } |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 178 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 179 | grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( |
| 180 | const grpc_channel_args *a) { |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 181 | size_t i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 182 | if (a == NULL) return 0; |
| 183 | for (i = 0; i < a->num_args; ++i) { |
| 184 | if (a->args[i].type == GRPC_ARG_INTEGER && |
| 185 | !strcmp(GRPC_COMPRESSION_ALGORITHM_ARG, a->args[i].key)) { |
| 186 | return (grpc_compression_algorithm)a->args[i].value.integer; |
| 187 | break; |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 188 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 189 | } |
David Garcia Quintas | cadbf22 | 2015-07-17 15:33:13 -0700 | [diff] [blame] | 190 | return GRPC_COMPRESS_NONE; |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 193 | grpc_channel_args *grpc_channel_args_set_compression_algorithm( |
| 194 | grpc_channel_args *a, grpc_compression_algorithm algorithm) { |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 195 | grpc_arg tmp; |
| 196 | tmp.type = GRPC_ARG_INTEGER; |
David Garcia Quintas | cadbf22 | 2015-07-17 15:33:13 -0700 | [diff] [blame] | 197 | tmp.key = GRPC_COMPRESSION_ALGORITHM_ARG; |
| 198 | tmp.value.integer = algorithm; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 199 | return grpc_channel_args_copy_and_add(a, &tmp, 1); |
David Garcia Quintas | cc6c43c | 2015-06-16 11:35:41 -0700 | [diff] [blame] | 200 | } |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 201 | |
| 202 | /** Returns 1 if the argument for compression algorithm's enabled states bitset |
| 203 | * was found in \a a, returning the arg's value in \a states. Otherwise, returns |
| 204 | * 0. */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 205 | static int find_compression_algorithm_states_bitset(const grpc_channel_args *a, |
| 206 | int **states_arg) { |
| 207 | if (a != NULL) { |
| 208 | size_t i; |
| 209 | for (i = 0; i < a->num_args; ++i) { |
| 210 | if (a->args[i].type == GRPC_ARG_INTEGER && |
| 211 | !strcmp(GRPC_COMPRESSION_ALGORITHM_STATE_ARG, a->args[i].key)) { |
| 212 | *states_arg = &a->args[i].value.integer; |
| 213 | return 1; /* GPR_TRUE */ |
| 214 | } |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 215 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 216 | } |
| 217 | return 0; /* GPR_FALSE */ |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 220 | grpc_channel_args *grpc_channel_args_compression_algorithm_set_state( |
| 221 | grpc_channel_args **a, grpc_compression_algorithm algorithm, int state) { |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 222 | int *states_arg; |
David Garcia Quintas | fe5f254 | 2015-08-24 12:33:05 -0700 | [diff] [blame] | 223 | grpc_channel_args *result = *a; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 224 | const int states_arg_found = |
| 225 | find_compression_algorithm_states_bitset(*a, &states_arg); |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 226 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 227 | if (states_arg_found) { |
| 228 | if (state != 0) { |
| 229 | GPR_BITSET((unsigned *)states_arg, algorithm); |
| 230 | } else { |
| 231 | GPR_BITCLEAR((unsigned *)states_arg, algorithm); |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 232 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 233 | } else { |
| 234 | /* create a new arg */ |
| 235 | grpc_arg tmp; |
| 236 | tmp.type = GRPC_ARG_INTEGER; |
| 237 | tmp.key = GRPC_COMPRESSION_ALGORITHM_STATE_ARG; |
| 238 | /* all enabled by default */ |
| 239 | tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; |
| 240 | if (state != 0) { |
| 241 | GPR_BITSET((unsigned *)&tmp.value.integer, algorithm); |
| 242 | } else { |
| 243 | GPR_BITCLEAR((unsigned *)&tmp.value.integer, algorithm); |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 244 | } |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 245 | result = grpc_channel_args_copy_and_add(*a, &tmp, 1); |
| 246 | grpc_channel_args_destroy(*a); |
| 247 | *a = result; |
| 248 | } |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 249 | return result; |
| 250 | } |
| 251 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 252 | int grpc_channel_args_compression_algorithm_get_states( |
| 253 | const grpc_channel_args *a) { |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 254 | int *states_arg; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 255 | if (find_compression_algorithm_states_bitset(a, &states_arg)) { |
| 256 | return *states_arg; |
| 257 | } else { |
| 258 | return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */ |
| 259 | } |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 260 | } |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 261 | |
Craig Tiller | 5de79ee | 2016-01-25 08:16:02 -0800 | [diff] [blame] | 262 | int grpc_channel_args_compare(const grpc_channel_args *a, |
Craig Tiller | edc2fff | 2016-01-13 06:54:27 -0800 | [diff] [blame] | 263 | const grpc_channel_args *b) { |
| 264 | int c = GPR_ICMP(a->num_args, b->num_args); |
| 265 | if (c != 0) return c; |
| 266 | for (size_t i = 0; i < a->num_args; i++) { |
| 267 | c = cmp_arg(&a->args[i], &b->args[i]); |
| 268 | if (c != 0) return c; |
| 269 | } |
| 270 | return 0; |
| 271 | } |