浏览代码

Cleanup existing code to use GPR_ARRAY_SIZE

Vijay Pai 10 年之前
父节点
当前提交
4473a087fe
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/core/iomgr/resolve_address_posix.c

+ 3 - 2
src/core/iomgr/resolve_address_posix.c

@@ -51,6 +51,7 @@
 #include <grpc/support/string_util.h>
 #include <grpc/support/string_util.h>
 #include <grpc/support/thd.h>
 #include <grpc/support/thd.h>
 #include <grpc/support/time.h>
 #include <grpc/support/time.h>
+#include <grpc/support/useful.h>
 
 
 typedef struct {
 typedef struct {
   char *name;
   char *name;
@@ -110,8 +111,8 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
   if (s != 0) {
   if (s != 0) {
     /* Retry if well-known service name is recognized */
     /* Retry if well-known service name is recognized */
     char *svc[][2] = {{"http", "80"}, {"https", "443"}};
     char *svc[][2] = {{"http", "80"}, {"https", "443"}};
-    int i;
-    for (i = 0; i < (int)(sizeof(svc) / sizeof(svc[0])); i++) {
+    size_t i;
+    for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
       if (strcmp(port, svc[i][0]) == 0) {
       if (strcmp(port, svc[i][0]) == 0) {
         GRPC_IOMGR_START_BLOCKING_REGION;
         GRPC_IOMGR_START_BLOCKING_REGION;
         s = getaddrinfo(host, svc[i][1], &hints, &result);
         s = getaddrinfo(host, svc[i][1], &hints, &result);