1
0

cherry-pick.softflowd-0.9.9-1-g91b2a2c.changes-for-avoidance-warnings-in-gcc-compilation-on-linux-ubuntu-12-04-openbsd-5-1-and-oracle-solaris-11-with-amd64-architecture-when-enables-enable-gcc-warnings-option-in-configure.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. Subject: Changes for avoidance warnings in gcc compilation on Linux (Ubuntu 12.04), OpenBSD 5.1 and Oracle solaris 11 with AMD64 architecture when enables "--enable-gcc-warnings" option in configure
  2. Origin: softflowd-0.9.9-1-g91b2a2c <https://github.com/irino/softflowd/commit/softflowd-0.9.9-1-g91b2a2c>
  3. Upstream-Author: Hitoshi Irino <hitoshi.irino@gmail.com>
  4. Date: Fri Sep 21 14:46:18 2012 +0900
  5. --- a/common.h
  6. +++ b/common.h
  7. @@ -57,6 +57,7 @@
  8. #include <signal.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. +#include <strings.h>
  12. #include <syslog.h>
  13. #include <time.h>
  14. @@ -166,4 +167,13 @@
  15. } __packed;
  16. #endif
  17. +
  18. +/* following lines are copy from unistd.h in Linux for avoidance warnings in compilation */
  19. +#if defined(HAVE_SETRESGID) && !defined(_GNU_SOURCE)
  20. +extern int setresgid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
  21. +#endif
  22. +#if defined(HAVE_SETRESUID) && !defined(_GNU_SOURCE)
  23. +extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
  24. +#endif
  25. +
  26. #endif /* _SFD_COMMON_H */
  27. --- a/netflow5.c
  28. +++ b/netflow5.c
  29. @@ -99,7 +99,7 @@
  30. hdr->flow_sequence = htonl(*flows_exported);
  31. if (option->sample > 0) {
  32. hdr->sampling_interval =
  33. - htons(0x01 << 14 | option->sample & 0x3FFF);
  34. + htons((0x01 << 14) | (option->sample & 0x3FFF));
  35. }
  36. /* Other fields are left zero */
  37. offset = sizeof(*hdr);
  38. --- a/softflowctl.c
  39. +++ b/softflowctl.c
  40. @@ -36,7 +36,9 @@
  41. const char *ctlsock_path;
  42. char buf[8192], *command;
  43. struct sockaddr_un ctl;
  44. +#ifdef SOCK_HAS_LEN
  45. socklen_t ctllen;
  46. +#endif
  47. int ctlsock, ch;
  48. FILE *ctlf;
  49. extern char *optarg;
  50. @@ -73,9 +75,9 @@
  51. }
  52. ctl.sun_path[sizeof(ctl.sun_path) - 1] = '\0';
  53. ctl.sun_family = AF_UNIX;
  54. +#ifdef SOCK_HAS_LEN
  55. ctllen = offsetof(struct sockaddr_un, sun_path) +
  56. strlen(ctlsock_path) + 1;
  57. -#ifdef SOCK_HAS_LEN
  58. ctl.sun_len = ctllen;
  59. #endif
  60. if ((ctlsock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
  61. --- a/softflowd.c
  62. +++ b/softflowd.c
  63. @@ -255,15 +255,15 @@
  64. static const char *
  65. format_flow(struct FLOW *flow)
  66. {
  67. - char addr1[64], addr2[64], stime[32], ftime[32];
  68. + char addr1[64], addr2[64], start_time[32], fin_time[32];
  69. static char buf[1024];
  70. inet_ntop(flow->af, &flow->addr[0], addr1, sizeof(addr1));
  71. inet_ntop(flow->af, &flow->addr[1], addr2, sizeof(addr2));
  72. - snprintf(stime, sizeof(ftime), "%s",
  73. + snprintf(start_time, sizeof(start_time), "%s",
  74. format_time(flow->flow_start.tv_sec));
  75. - snprintf(ftime, sizeof(ftime), "%s",
  76. + snprintf(fin_time, sizeof(fin_time), "%s",
  77. format_time(flow->flow_last.tv_sec));
  78. snprintf(buf, sizeof(buf), "seq:%"PRIu64" [%s]:%hu <> [%s]:%hu proto:%u "
  79. @@ -275,8 +275,8 @@
  80. (int)flow->protocol,
  81. flow->octets[0], flow->packets[0],
  82. flow->octets[1], flow->packets[1],
  83. - stime, (flow->flow_start.tv_usec + 500) / 1000,
  84. - ftime, (flow->flow_last.tv_usec + 500) / 1000,
  85. + start_time, (flow->flow_start.tv_usec + 500) / 1000,
  86. + fin_time, (flow->flow_last.tv_usec + 500) / 1000,
  87. flow->tcp_flags[0], flow->tcp_flags[1],
  88. flow->ip6_flowlabel[0], flow->ip6_flowlabel[1]);
  89. @@ -1163,7 +1163,7 @@
  90. accept_control(int lsock, struct NETFLOW_TARGET *target, struct FLOWTRACK *ft,
  91. pcap_t *pcap, int *exit_request, int *stop_collection_flag)
  92. {
  93. - unsigned char buf[64], *p;
  94. + char buf[64], *p;
  95. FILE *ctlf;
  96. int fd, ret;
  97. @@ -1202,61 +1202,61 @@
  98. ret = 0;
  99. } else if (strcmp(buf, "shutdown") == 0) {
  100. fprintf(ctlf, "softflowd[%u]: Shutting down gracefully...\n",
  101. - getpid());
  102. + (unsigned int)getpid());
  103. graceful_shutdown_request = 1;
  104. ret = 1;
  105. } else if (strcmp(buf, "exit") == 0) {
  106. - fprintf(ctlf, "softflowd[%u]: Exiting now...\n", getpid());
  107. + fprintf(ctlf, "softflowd[%u]: Exiting now...\n", (unsigned int)getpid());
  108. *exit_request = 1;
  109. ret = 1;
  110. } else if (strcmp(buf, "expire-all") == 0) {
  111. netflow9_resend_template();
  112. - fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", getpid(),
  113. + fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", (unsigned int)getpid(),
  114. check_expired(ft, target, CE_EXPIRE_ALL));
  115. ret = 0;
  116. } else if (strcmp(buf, "send-template") == 0) {
  117. netflow9_resend_template();
  118. fprintf(ctlf, "softflowd[%u]: Template will be sent at "
  119. - "next flow export\n", getpid());
  120. + "next flow export\n", (unsigned int)getpid());
  121. ret = 0;
  122. } else if (strcmp(buf, "delete-all") == 0) {
  123. - fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", getpid(),
  124. + fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", (unsigned int)getpid(),
  125. delete_all_flows(ft));
  126. ret = 0;
  127. } else if (strcmp(buf, "statistics") == 0) {
  128. fprintf(ctlf, "softflowd[%u]: Accumulated statistics "
  129. - "since %s UTC:\n", getpid(),
  130. + "since %s UTC:\n", (unsigned int)getpid(),
  131. format_time(ft->system_boot_time.tv_sec));
  132. statistics(ft, ctlf, pcap);
  133. ret = 0;
  134. } else if (strcmp(buf, "debug+") == 0) {
  135. fprintf(ctlf, "softflowd[%u]: Debug level increased.\n",
  136. - getpid());
  137. + (unsigned int)getpid());
  138. verbose_flag = 1;
  139. ret = 0;
  140. } else if (strcmp(buf, "debug-") == 0) {
  141. fprintf(ctlf, "softflowd[%u]: Debug level decreased.\n",
  142. - getpid());
  143. + (unsigned int)getpid());
  144. verbose_flag = 0;
  145. ret = 0;
  146. } else if (strcmp(buf, "stop-gather") == 0) {
  147. fprintf(ctlf, "softflowd[%u]: Data collection stopped.\n",
  148. - getpid());
  149. + (unsigned int)getpid());
  150. *stop_collection_flag = 1;
  151. ret = 0;
  152. } else if (strcmp(buf, "start-gather") == 0) {
  153. fprintf(ctlf, "softflowd[%u]: Data collection resumed.\n",
  154. - getpid());
  155. + (unsigned int)getpid());
  156. *stop_collection_flag = 0;
  157. ret = 0;
  158. } else if (strcmp(buf, "dump-flows") == 0) {
  159. fprintf(ctlf, "softflowd[%u]: Dumping flow data:\n",
  160. - getpid());
  161. + (unsigned int)getpid());
  162. dump_flows(ft, ctlf);
  163. ret = 0;
  164. } else if (strcmp(buf, "timeouts") == 0) {
  165. fprintf(ctlf, "softflowd[%u]: Printing timeouts:\n",
  166. - getpid());
  167. + (unsigned int)getpid());
  168. print_timeouts(ft, ctlf);
  169. ret = 0;
  170. } else {
  171. @@ -1868,7 +1868,7 @@
  172. pidfile_path, strerror(errno));
  173. exit(1);
  174. }
  175. - fprintf(pidfile, "%u\n", getpid());
  176. + fprintf(pidfile, "%u\n", (unsigned int)getpid());
  177. fclose(pidfile);
  178. signal(SIGINT, sighand_graceful_shutdown);