]> code.ossystems Code Review - openembedded-core.git/blob
a5af49f84eea57651d58b83dda29667da1fcdb45
[openembedded-core.git] /
1 Upstream-Status: Backport
2
3 From a55a8fd83be9d91bd2adb73eebac8833a51b626f Mon Sep 17 00:00:00 2001
4 From: Stephen Hemminger <stephen@networkplumber.org>
5 Date: Thu, 28 Feb 2013 08:51:46 -0800
6 Subject: [PATCH] fix dependency on sizeof(__u64) == sizeof(unsigned long
7  long)
8
9 Some platforms like ppc64 have unsigned long long as 128 bits, and
10 the printf format string would cause errors. Resolve this by using
11 unsigned long long where necessary (or unsigned long).
12 ---
13  ip/ipntable.c    |   74 +++++++++++++++++++++---------------------------------
14  ip/tcp_metrics.c |   13 +++++-----
15  2 files changed, 35 insertions(+), 52 deletions(-)
16
17 diff --git a/ip/ipntable.c b/ip/ipntable.c
18 index 56ad001..a1a3c26 100644
19 --- a/ip/ipntable.c
20 +++ b/ip/ipntable.c
21 @@ -431,8 +431,8 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
22                 fprintf(fp, "thresh3 %u ", thresh3);
23         }
24         if (tb[NDTA_GC_INTERVAL]) {
25 -               __u64 gc_int = rta_getattr_u64(tb[NDTA_GC_INTERVAL]);
26 -               fprintf(fp, "gc_int %llu ", (unsigned long long) gc_int);
27 +               unsigned long long gc_int = rta_getattr_u64(tb[NDTA_GC_INTERVAL]);
28 +               fprintf(fp, "gc_int %llu ", gc_int);
29         }
30  
31         if (ret)
32 @@ -484,19 +484,16 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
33                         fprintf(fp, "refcnt %u ", refcnt);
34                 }
35                 if (tpb[NDTPA_REACHABLE_TIME]) {
36 -                       __u64 reachable = rta_getattr_u64(tpb[NDTPA_REACHABLE_TIME]);
37 -                       fprintf(fp, "reachable %llu ",
38 -                               (unsigned long long) reachable);
39 +                       unsigned long long reachable = rta_getattr_u64(tpb[NDTPA_REACHABLE_TIME]);
40 +                       fprintf(fp, "reachable %llu ", reachable);
41                 }
42                 if (tpb[NDTPA_BASE_REACHABLE_TIME]) {
43 -                       __u64 breachable = rta_getattr_u64(tpb[NDTPA_BASE_REACHABLE_TIME]);
44 -                       fprintf(fp, "base_reachable %llu ",
45 -                               (unsigned long long) breachable);
46 +                       unsigned long long breachable = rta_getattr_u64(tpb[NDTPA_BASE_REACHABLE_TIME]);
47 +                       fprintf(fp, "base_reachable %llu ", breachable);
48                 }
49                 if (tpb[NDTPA_RETRANS_TIME]) {
50 -                       __u64 retrans = rta_getattr_u64(tpb[NDTPA_RETRANS_TIME]);
51 -                       fprintf(fp, "retrans %llu ",
52 -                               (unsigned long long) retrans);
53 +                       unsigned long long retrans = rta_getattr_u64(tpb[NDTPA_RETRANS_TIME]);
54 +                       fprintf(fp, "retrans %llu ", retrans);
55                 }
56  
57                 fprintf(fp, "%s", _SL_);
58 @@ -504,14 +501,12 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
59                 fprintf(fp, "    ");
60  
61                 if (tpb[NDTPA_GC_STALETIME]) {
62 -                       __u64 gc_stale = rta_getattr_u64(tpb[NDTPA_GC_STALETIME]);
63 -                       fprintf(fp, "gc_stale %llu ",
64 -                               (unsigned long long) gc_stale);
65 +                       unsigned long long gc_stale = rta_getattr_u64(tpb[NDTPA_GC_STALETIME]);
66 +                       fprintf(fp, "gc_stale %llu ", gc_stale);
67                 }
68                 if (tpb[NDTPA_DELAY_PROBE_TIME]) {
69 -                       __u64 delay_probe = rta_getattr_u64(tpb[NDTPA_DELAY_PROBE_TIME]);
70 -                       fprintf(fp, "delay_probe %llu ",
71 -                               (unsigned long long) delay_probe);
72 +                       unsigned long long delay_probe = rta_getattr_u64(tpb[NDTPA_DELAY_PROBE_TIME]);
73 +                       fprintf(fp, "delay_probe %llu ", delay_probe);
74                 }
75                 if (tpb[NDTPA_QUEUE_LEN]) {
76                         __u32 queue = rta_getattr_u32(tpb[NDTPA_QUEUE_LEN]);
77 @@ -540,23 +535,20 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
78                 fprintf(fp, "    ");
79  
80                 if (tpb[NDTPA_ANYCAST_DELAY]) {
81 -                       __u64 anycast_delay = rta_getattr_u64(tpb[NDTPA_ANYCAST_DELAY]);
82 -                       fprintf(fp, "anycast_delay %llu ",
83 -                               (unsigned long long) anycast_delay);
84 +                       unsigned long long anycast_delay = rta_getattr_u64(tpb[NDTPA_ANYCAST_DELAY]);
85 +                       fprintf(fp, "anycast_delay %llu ", anycast_delay);
86                 }
87                 if (tpb[NDTPA_PROXY_DELAY]) {
88 -                       __u64 proxy_delay = rta_getattr_u64(tpb[NDTPA_PROXY_DELAY]);
89 -                       fprintf(fp, "proxy_delay %llu ",
90 -                               (unsigned long long) proxy_delay);
91 +                       unsigned long long proxy_delay = rta_getattr_u64(tpb[NDTPA_PROXY_DELAY]);
92 +                       fprintf(fp, "proxy_delay %llu ", proxy_delay);
93                 }
94                 if (tpb[NDTPA_PROXY_QLEN]) {
95                         __u32 pqueue = rta_getattr_u32(tpb[NDTPA_PROXY_QLEN]);
96                         fprintf(fp, "proxy_queue %u ", pqueue);
97                 }
98                 if (tpb[NDTPA_LOCKTIME]) {
99 -                       __u64 locktime = rta_getattr_u64(tpb[NDTPA_LOCKTIME]);
100 -                       fprintf(fp, "locktime %llu ",
101 -                               (unsigned long long) locktime);
102 +                       unsigned long long locktime = rta_getattr_u64(tpb[NDTPA_LOCKTIME]);
103 +                       fprintf(fp, "locktime %llu ", locktime);
104                 }
105  
106                 fprintf(fp, "%s", _SL_);
107 @@ -568,38 +560,28 @@ int print_ntable(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
108                 fprintf(fp, "    ");
109                 fprintf(fp, "stats ");
110  
111 -               fprintf(fp, "allocs %llu ",
112 -                       (unsigned long long) ndts->ndts_allocs);
113 -               fprintf(fp, "destroys %llu ",
114 -                       (unsigned long long) ndts->ndts_destroys);
115 -               fprintf(fp, "hash_grows %llu ",
116 -                       (unsigned long long) ndts->ndts_hash_grows);
117 +               fprintf(fp, "allocs %llu ", ndts->ndts_allocs);
118 +               fprintf(fp, "destroys %llu ", ndts->ndts_destroys);
119 +               fprintf(fp, "hash_grows %llu ", ndts->ndts_hash_grows);
120  
121                 fprintf(fp, "%s", _SL_);
122                 fprintf(fp, "        ");
123  
124 -               fprintf(fp, "res_failed %llu ",
125 -                       (unsigned long long) ndts->ndts_res_failed);
126 -               fprintf(fp, "lookups %llu ",
127 -                       (unsigned long long) ndts->ndts_lookups);
128 -               fprintf(fp, "hits %llu ",
129 -                       (unsigned long long) ndts->ndts_hits);
130 +               fprintf(fp, "res_failed %llu ", ndts->ndts_res_failed);
131 +               fprintf(fp, "lookups %llu ", ndts->ndts_lookups);
132 +               fprintf(fp, "hits %llu ", ndts->ndts_hits);
133  
134                 fprintf(fp, "%s", _SL_);
135                 fprintf(fp, "        ");
136  
137 -               fprintf(fp, "rcv_probes_mcast %llu ",
138 -                       (unsigned long long) ndts->ndts_rcv_probes_mcast);
139 -               fprintf(fp, "rcv_probes_ucast %llu ",
140 -                       (unsigned long long) ndts->ndts_rcv_probes_ucast);
141 +               fprintf(fp, "rcv_probes_mcast %llu ", ndts->ndts_rcv_probes_mcast);
142 +               fprintf(fp, "rcv_probes_ucast %llu ", ndts->ndts_rcv_probes_ucast);
143  
144                 fprintf(fp, "%s", _SL_);
145                 fprintf(fp, "        ");
146  
147 -               fprintf(fp, "periodic_gc_runs %llu ",
148 -                       (unsigned long long) ndts->ndts_periodic_gc_runs);
149 -               fprintf(fp, "forced_gc_runs %llu ",
150 -                       (unsigned long long) ndts->ndts_forced_gc_runs);
151 +               fprintf(fp, "periodic_gc_runs %llu ", ndts->ndts_periodic_gc_runs);
152 +               fprintf(fp, "forced_gc_runs %llu ", ndts->ndts_forced_gc_runs);
153  
154                 fprintf(fp, "%s", _SL_);
155         }
156 diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c
157 index a01e1fb..c6be3c9 100644
158 --- a/ip/tcp_metrics.c
159 +++ b/ip/tcp_metrics.c
160 @@ -166,7 +166,7 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
161  
162         a = attrs[TCP_METRICS_ATTR_AGE];
163         if (a) {
164 -               __u64 val = rta_getattr_u64(a);
165 +               unsigned long long val = rta_getattr_u64(a);
166  
167                 fprintf(fp, " age %llu.%03llusec",
168                         val / 1000, val % 1000);
169 @@ -189,7 +189,7 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
170                 parse_rtattr_nested(m, TCP_METRIC_MAX + 1, a);
171  
172                 for (i = 0; i < TCP_METRIC_MAX + 1; i++) {
173 -                       __u32 val;
174 +                       unsigned long val;
175  
176                         a = m[i + 1];
177                         if (!a)
178 @@ -198,19 +198,20 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
179                                 fprintf(fp, " %s ", metric_name[i]);
180                         else
181                                 fprintf(fp, " metric_%d ", i);
182 +
183                         val = rta_getattr_u32(a);
184                         switch (i) {
185                         case TCP_METRIC_RTT:
186 -                               fprintf(fp, "%lluus", (val * 1000ULL) >> 3);
187 +                               fprintf(fp, "%luus", (val * 1000UL) >> 3);
188                                 break;
189                         case TCP_METRIC_RTTVAR:
190 -                               fprintf(fp, "%lluus", (val * 1000ULL) >> 2);
191 +                               fprintf(fp, "%luus", (val * 1000UL) >> 2);
192                                 break;
193                         case TCP_METRIC_SSTHRESH:
194                         case TCP_METRIC_CWND:
195                         case TCP_METRIC_REORDERING:
196                         default:
197 -                               fprintf(fp, "%u", val);
198 +                               fprintf(fp, "%lu", val);
199                                 break;
200                         }
201                 }
202 @@ -223,7 +224,7 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n,
203         a = attrs[TCP_METRICS_ATTR_FOPEN_SYN_DROPS];
204         if (a) {
205                 __u16 syn_loss = rta_getattr_u16(a);
206 -               __u64 ts;
207 +               unsigned long long ts;
208  
209                 a = attrs[TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS];
210                 ts = a ? rta_getattr_u64(a) : 0;
211 -- 
212 1.7.9.7
213