Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.2 KiB

  1. From a53fb3d0ccb42e59b0ce2e3fa6f141da106a7294 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <busterb@gmail.com>
  3. Date: Mon, 19 Jan 2015 04:37:59 -0600
  4. Subject: [PATCH 13/13] log context of all fatal allocations
  5. ---
  6. src/usr.sbin/ntpd/config.c | 8 ++++----
  7. src/usr.sbin/ntpd/ntp.c | 8 ++++----
  8. src/usr.sbin/ntpd/ntp_dns.c | 2 +-
  9. src/usr.sbin/ntpd/ntpd.c | 6 +++---
  10. src/usr.sbin/ntpd/parse.y | 6 +++---
  11. 5 files changed, 15 insertions(+), 15 deletions(-)
  12. diff --git a/src/usr.sbin/ntpd/config.c b/src/usr.sbin/ntpd/config.c
  13. index 9777110..56b50d2 100644
  14. --- a/src/usr.sbin/ntpd/config.c
  15. +++ b/src/usr.sbin/ntpd/config.c
  16. @@ -41,7 +41,7 @@ host(const char *s, struct ntp_addr **hn)
  17. if (!strcmp(s, "*"))
  18. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  19. - fatal(NULL);
  20. + fatal("ntp_addr calloc");
  21. /* IPv4 address? */
  22. if (h == NULL)
  23. @@ -69,7 +69,7 @@ host_v4(const char *s)
  24. return (NULL);
  25. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  26. - fatal(NULL);
  27. + fatal("ntp_addr calloc");
  28. sa_in = (struct sockaddr_in *)&h->ss;
  29. #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  30. sa_in->sin_len = sizeof(struct sockaddr_in);
  31. @@ -93,7 +93,7 @@ host_v6(const char *s)
  32. hints.ai_flags = AI_NUMERICHOST;
  33. if (getaddrinfo(s, "0", &hints, &res) == 0) {
  34. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  35. - fatal(NULL);
  36. + fatal("ntp_addr calloc");
  37. sa_in6 = (struct sockaddr_in6 *)&h->ss;
  38. #ifdef SIN6_LEN
  39. sa_in6->sin6_len = sizeof(struct sockaddr_in6);
  40. @@ -154,7 +154,7 @@ host_dns(const char *s, struct ntp_addr **hn)
  41. res->ai_family != AF_INET6)
  42. continue;
  43. if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
  44. - fatal(NULL);
  45. + fatal("ntp_addr calloc");
  46. h->ss.ss_family = res->ai_family;
  47. if (res->ai_family == AF_INET) {
  48. sa_in = (struct sockaddr_in *)&h->ss;
  49. diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c
  50. index c8f095e..7db98f6 100644
  51. --- a/src/usr.sbin/ntpd/ntp.c
  52. +++ b/src/usr.sbin/ntpd/ntp.c
  53. @@ -112,7 +112,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
  54. fatal("getservbyname");
  55. if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
  56. - fatal(NULL);
  57. + fatal("open /dev/null");
  58. hotplugfd = sensor_hotplugfd();
  59. close(pipe_prnt[0]);
  60. @@ -166,10 +166,10 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
  61. signal(SIGCHLD, SIG_DFL);
  62. if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL)
  63. - fatal(NULL);
  64. + fatal("ibuf_main malloc");
  65. imsg_init(ibuf_main, pipe_prnt[1]);
  66. if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL)
  67. - fatal(NULL);
  68. + fatal("ibuf_dns malloc");
  69. imsg_init(ibuf_dns, pipe_dns[0]);
  70. TAILQ_FOREACH(p, &conf->ntp_peers, entry)
  71. @@ -508,7 +508,7 @@ ntp_dispatch_imsg_dns(void)
  72. while (dlen >= sizeof(struct sockaddr_storage)) {
  73. if ((h = calloc(1, sizeof(struct ntp_addr))) ==
  74. NULL)
  75. - fatal(NULL);
  76. + fatal("ntp_addr calloc");
  77. memcpy(&h->ss, p, sizeof(h->ss));
  78. p += sizeof(h->ss);
  79. dlen -= sizeof(h->ss);
  80. diff --git a/src/usr.sbin/ntpd/ntp_dns.c b/src/usr.sbin/ntpd/ntp_dns.c
  81. index 14e6b76..b77d486 100644
  82. --- a/src/usr.sbin/ntpd/ntp_dns.c
  83. +++ b/src/usr.sbin/ntpd/ntp_dns.c
  84. @@ -87,7 +87,7 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw)
  85. signal(SIGHUP, sighdlr_dns);
  86. if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL)
  87. - fatal(NULL);
  88. + fatal("imsgbuf malloc");
  89. imsg_init(ibuf_dns, pipe_ntp[1]);
  90. while (quit_dns == 0) {
  91. diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
  92. index 26463f6..b65deb7 100644
  93. --- a/src/usr.sbin/ntpd/ntpd.c
  94. +++ b/src/usr.sbin/ntpd/ntpd.c
  95. @@ -239,7 +239,7 @@ main(int argc, char *argv[])
  96. close(pipe_chld[1]);
  97. if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
  98. - fatal(NULL);
  99. + fatal("imsgbuf malloc");
  100. imsg_init(ibuf, pipe_chld[0]);
  101. while (quit == 0) {
  102. @@ -623,7 +623,7 @@ ctl_main(int argc, char *argv[])
  103. break;
  104. }
  105. }
  106. - if (action == -1)
  107. + if (action == -1)
  108. usage();
  109. /* NOTREACHED */
  110. @@ -639,7 +639,7 @@ ctl_main(int argc, char *argv[])
  111. err(1, "connect: %s", sockname);
  112. if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL)
  113. - err(1, NULL);
  114. + err(1, "malloc: imsgbuf");
  115. imsg_init(ibuf_ctl, fd);
  116. switch (action) {
  117. diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
  118. index 42a49f7..285fae8 100644
  119. --- a/src/usr.sbin/ntpd/parse.y
  120. +++ b/src/usr.sbin/ntpd/parse.y
  121. @@ -161,7 +161,7 @@ main : LISTEN ON address listen_opts {
  122. p->addr_head.pool = 1;
  123. p->addr_head.name = strdup($2->name);
  124. if (p->addr_head.name == NULL)
  125. - fatal(NULL);
  126. + fatal("servers strdup");
  127. if (p->addr != NULL)
  128. p->state = STATE_DNS_DONE;
  129. if (!(p->rtable > 0 && p->addr))
  130. @@ -200,7 +200,7 @@ main : LISTEN ON address listen_opts {
  131. p->addr_head.pool = 0;
  132. p->addr_head.name = strdup($2->name);
  133. if (p->addr_head.name == NULL)
  134. - fatal(NULL);
  135. + fatal("server strdup");
  136. if (p->addr != NULL)
  137. p->state = STATE_DNS_DONE;
  138. if (!(p->rtable > 0 && p->addr))
  139. @@ -224,7 +224,7 @@ main : LISTEN ON address listen_opts {
  140. address : STRING {
  141. if (($$ = calloc(1, sizeof(struct ntp_addr_wrap))) ==
  142. NULL)
  143. - fatal(NULL);
  144. + fatal("ntp_addr_wrap calloc");
  145. host($1, &$$->a);
  146. $$->name = $1;
  147. }
  148. --
  149. 1.9.1