Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove useless casts from calloc

  • Loading branch information...
commit 8d38c71332758e6ec38ff345412857ab73d99d09 1 parent 230cebf
Michael Santos authored June 02, 2011
6  ds/ds.c
@@ -122,7 +122,7 @@ main (int argc, char *argv[])
122 122
 
123 123
     int ch = 0;
124 124
 
125  
-    IS_NULL(ds = (DS_STATE *)calloc(1, sizeof(DS_STATE)));
  125
+    IS_NULL(ds = calloc(1, sizeof(DS_STATE)));
126 126
 
127 127
     ds->queryhost = HOSTNAME;
128 128
     ds->port.remote = 53;
@@ -202,7 +202,7 @@ ds_writer(DS_STATE *ds)
202 202
 
203 203
     struct in_addr ia;
204 204
 
205  
-    IS_NULL(buf = (u_char *)calloc(1, NS_PACKETSZ));
  205
+    IS_NULL(buf = calloc(1, NS_PACKETSZ));
206 206
 
207 207
     if (res_mkquery(ns_o_query, HOSTNAME, ns_c_in, ns_t_a, NULL, 0, NULL, buf, NS_PACKETSZ) < 0)
208 208
         errx(EXIT_FAILURE, "%s", hstrerror(h_errno));
@@ -230,7 +230,7 @@ ds_reader(DS_STATE *ds)
230 230
     char *status = NULL;
231 231
     char *rerr = NULL;
232 232
 
233  
-    IS_NULL(buf = (u_char *)calloc(1, NS_PACKETSZ));
  233
+    IS_NULL(buf = calloc(1, NS_PACKETSZ));
234 234
 
235 235
     for ( ; ; ) {
236 236
         if (woken > 0) return;
6  sdt/sdt.c
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
42 42
     int ch = 0;
43 43
     int di = 0;
44 44
 
45  
-    IS_NULL(ss = (SDT_STATE *)calloc(1, sizeof(SDT_STATE)));
  45
+    IS_NULL(ss = calloc(1, sizeof(SDT_STATE)));
46 46
 
47 47
     sdt_rand_init();
48 48
     (void)sdt_dns_init();
@@ -163,7 +163,7 @@ main(int argc, char *argv[])
163 163
         usage(ss);
164 164
 
165 165
     ss->dname_max = argc;
166  
-    IS_NULL(ss->dname = (char **)calloc(argc, sizeof(char *)));
  166
+    IS_NULL(ss->dname = calloc(argc, sizeof(char *)));
167 167
     for ( di = 0; di < argc; di++) {
168 168
         if (strlen(argv[di]) > NS_MAXCDNAME - 1)
169 169
             usage(ss);
@@ -343,7 +343,7 @@ sdt_loop_A(SDT_STATE *ss)
343 343
     flags |= O_NONBLOCK;
344 344
     (void)fcntl(ss->fd_in, F_SETFL, flags);
345 345
 
346  
-    IS_NULL(buf = (char *)calloc(ss->bufsz, 1));
  346
+    IS_NULL(buf = calloc(ss->bufsz, 1));
347 347
 
348 348
     while ( (n = sdt_read(ss, buf, ss->bufsz)) > 0) {
349 349
         VERBOSE(3, "Sending A record: %d of %u bytes\n", (int32_t)n, (u_int32_t)ss->bufsz);
2  sdt/sdt_dns.c
@@ -322,7 +322,7 @@ sdt_dns_dec_CNAME(SDT_STATE *ss, u_char *data, u_int16_t *n)
322 322
     char *buf = NULL;
323 323
     char b32[NS_PACKETSZ];
324 324
 
325  
-    IS_NULL(buf = (char *)calloc(NS_PACKETSZ, 1));
  325
+    IS_NULL(buf = calloc(NS_PACKETSZ, 1));
326 326
 
327 327
     if (dn_expand( (const u_char *)data, (const u_char *)data + *n,
328 328
                 (const u_char *)data, b32, NS_PACKETSZ) < 0) {
8  sods/sods.c
@@ -41,7 +41,7 @@ main (int argc, char *argv[])
41 41
     int ch = 0;
42 42
     int di = 0;
43 43
 
44  
-    IS_NULL(ss = (SDS_STATE *)calloc(1, sizeof(SDS_STATE)));
  44
+    IS_NULL(ss = calloc(1, sizeof(SDS_STATE)));
45 45
 
46 46
     (void)memset(&ss->local, 0, sizeof(struct sockaddr_in));
47 47
     ss->local.sin_family = AF_INET;
@@ -107,7 +107,7 @@ main (int argc, char *argv[])
107 107
         usage(ss);
108 108
 
109 109
     ss->dn_max = argc;
110  
-    IS_NULL(ss->dn = (char **)calloc(argc, sizeof(char *)));
  110
+    IS_NULL(ss->dn = calloc(argc, sizeof(char *)));
111 111
     for ( di = 0; di < argc; di++) {
112 112
         if (strlen(argv[di]) > NS_MAXCDNAME - 1)
113 113
             usage(ss);
@@ -150,9 +150,9 @@ sds_parse_forward(SDS_STATE *ss, char *buf)
150 150
     }
151 151
 
152 152
     if (ss->fwd == NULL)
153  
-        IS_NULL(ss->fwd = (SDS_FWD *)calloc(1, sizeof(SDS_FWD)));
  153
+        IS_NULL(ss->fwd = calloc(1, sizeof(SDS_FWD)));
154 154
     else
155  
-        IS_NULL(ss->fwd = (SDS_FWD *)realloc(ss->fwd, sizeof(SDS_FWD) * (ss->fwds + 1)));
  155
+        IS_NULL(ss->fwd = realloc(ss->fwd, sizeof(SDS_FWD) * (ss->fwds + 1)));
156 156
 
157 157
     fw = ss->fwd + ss->fwds;
158 158
 
6  sods/sods_dns.c
@@ -109,7 +109,7 @@ sds_dns_query_A(void *state, void *packet)
109 109
     int rv = -1;
110 110
 
111 111
     IS_NULL(b32 = strdup(pkt->buf));
112  
-    IS_NULL(domain = (char *)calloc(NS_MAXDNAME, 1));
  112
+    IS_NULL(domain = calloc(NS_MAXDNAME, 1));
113 113
 
114 114
     /*%s.%u-%u.id-%d.up.%s */
115 115
     /* parse out the base32 encoded data */
@@ -160,7 +160,7 @@ sds_dns_query_TXT(void *state, void *packet)
160 160
     char *domain = NULL;
161 161
     int rv = -1;
162 162
 
163  
-    IS_NULL(domain = (char *)calloc(NS_MAXDNAME, 1));
  163
+    IS_NULL(domain = calloc(NS_MAXDNAME, 1));
164 164
 
165 165
     if (sscanf(pkt->buf, "%u-%u.id-%u.down.%32s", (u_int32_t *)&pkt->sum,
166 166
                 &nonce, &pkt->sess.id, domain) != 4)
@@ -282,7 +282,7 @@ sds_dns_enc_CNAME(void *state, void *packet)
282 282
 
283 283
     NULL_RESPONSE(pkt);
284 284
 
285  
-    IS_NULL(buf = (char *)calloc(sizeof(pkt->buf), 1));
  285
+    IS_NULL(buf = calloc(sizeof(pkt->buf), 1));
286 286
 
287 287
     n = base32_encode_length(pkt->buflen); /* len includes NULL */
288 288
     if (n + (n/NS_MAXLABEL + 1) + 1 >= sizeof(pkt->buf)) {
2  sods/sods_io.c
@@ -189,7 +189,7 @@ sds_io_alloc(SDS_STATE *ss, SDS_PKT *pkt)
189 189
     if (sds_q_init() < 0)
190 190
         errx(1, "sds_q_init");
191 191
 
192  
-    IS_NULL(sc = (SDS_CONN *)calloc(1, sizeof(SDS_CONN)));
  192
+    IS_NULL(sc = calloc(1, sizeof(SDS_CONN)));
193 193
 
194 194
     sc->id = pkt->sess.f.id;
195 195
     sc->lastseen = time(NULL);
2  sods/sods_sock.c
@@ -50,7 +50,7 @@ sds_sock_loop(void *vp)
50 50
     SDS_STATE *ss = (SDS_STATE *)vp;
51 51
     SDS_PKT *pkt = NULL;
52 52
 
53  
-    IS_NULL(pkt = (SDS_PKT *)calloc(1, sizeof(SDS_PKT)));
  53
+    IS_NULL(pkt = calloc(1, sizeof(SDS_PKT)));
54 54
 
55 55
     (void)sds_sock_init(ss);
56 56
 

0 notes on commit 8d38c71

Please sign in to comment.
Something went wrong with that request. Please try again.