Tue Aug 11 20:48:07 2009 UTC ()
Fix some lint warnings about G/C unused variables and changing a
variable type to match the return type of fetch_read.


(joerg)
diff -r1.18 -r1.19 pkgsrc/net/libfetch/files/common.c
diff -r1.18 -r1.19 pkgsrc/net/libfetch/files/fetch.c

cvs diff -r1.18 -r1.19 pkgsrc/net/libfetch/files/common.c (expand / switch to unified diff)

--- pkgsrc/net/libfetch/files/common.c 2009/02/22 19:11:48 1.18
+++ pkgsrc/net/libfetch/files/common.c 2009/08/11 20:48:06 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: common.c,v 1.18 2009/02/22 19:11:48 joerg Exp $ */ 1/* $NetBSD: common.c,v 1.19 2009/08/11 20:48:06 joerg Exp $ */
2/*- 2/*-
3 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav 3 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
4 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> 4 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer 11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged. 12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -251,37 +251,37 @@ fetch_ref(conn_t *conn) @@ -251,37 +251,37 @@ fetch_ref(conn_t *conn)
251 251
252 ++conn->ref; 252 ++conn->ref;
253 return (conn); 253 return (conn);
254} 254}
255 255
256 256
257/* 257/*
258 * Bind a socket to a specific local address 258 * Bind a socket to a specific local address
259 */ 259 */
260int 260int
261fetch_bind(int sd, int af, const char *addr) 261fetch_bind(int sd, int af, const char *addr)
262{ 262{
263 struct addrinfo hints, *res, *res0; 263 struct addrinfo hints, *res, *res0;
264 int error; 
265 264
266 memset(&hints, 0, sizeof(hints)); 265 memset(&hints, 0, sizeof(hints));
267 hints.ai_family = af; 266 hints.ai_family = af;
268 hints.ai_socktype = SOCK_STREAM; 267 hints.ai_socktype = SOCK_STREAM;
269 hints.ai_protocol = 0; 268 hints.ai_protocol = 0;
270 if ((error = getaddrinfo(addr, NULL, &hints, &res0)) != 0) 269 if (getaddrinfo(addr, NULL, &hints, &res0))
271 return (-1); 270 return (-1);
272 for (res = res0; res; res = res->ai_next) 271 for (res = res0; res; res = res->ai_next) {
273 if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) 272 if (bind(sd, res->ai_addr, res->ai_addrlen) == 0)
274 return (0); 273 return (0);
 274 }
275 return (-1); 275 return (-1);
276} 276}
277 277
278 278
279/* 279/*
280 * Establish a TCP connection to the specified port on the specified host. 280 * Establish a TCP connection to the specified port on the specified host.
281 */ 281 */
282conn_t * 282conn_t *
283fetch_connect(const char *host, int port, int af, int verbose) 283fetch_connect(const char *host, int port, int af, int verbose)
284{ 284{
285 conn_t *conn; 285 conn_t *conn;
286 char pbuf[10]; 286 char pbuf[10];
287 const char *bindaddr; 287 const char *bindaddr;
@@ -604,27 +604,27 @@ fetch_writev(conn_t *conn, struct iovec  @@ -604,27 +604,27 @@ fetch_writev(conn_t *conn, struct iovec
604 } 604 }
605 } 605 }
606 return (total); 606 return (total);
607} 607}
608 608
609 609
610/* 610/*
611 * Write a line of text to a connection w/ timeout 611 * Write a line of text to a connection w/ timeout
612 */ 612 */
613int 613int
614fetch_putln(conn_t *conn, const char *str, size_t len) 614fetch_putln(conn_t *conn, const char *str, size_t len)
615{ 615{
616 struct iovec iov[2]; 616 struct iovec iov[2];
617 int ret; 617 ssize_t ret;
618 618
619 iov[0].iov_base = DECONST(char *, str); 619 iov[0].iov_base = DECONST(char *, str);
620 iov[0].iov_len = len; 620 iov[0].iov_len = len;
621 iov[1].iov_base = DECONST(char *, ENDL); 621 iov[1].iov_base = DECONST(char *, ENDL);
622 iov[1].iov_len = sizeof(ENDL); 622 iov[1].iov_len = sizeof(ENDL);
623 if (len == 0) 623 if (len == 0)
624 ret = fetch_writev(conn, &iov[1], 1); 624 ret = fetch_writev(conn, &iov[1], 1);
625 else 625 else
626 ret = fetch_writev(conn, iov, 2); 626 ret = fetch_writev(conn, iov, 2);
627 if (ret == -1) 627 if (ret == -1)
628 return (-1); 628 return (-1);
629 return (0); 629 return (0);
630} 630}

cvs diff -r1.18 -r1.19 pkgsrc/net/libfetch/files/fetch.c (expand / switch to unified diff)

--- pkgsrc/net/libfetch/files/fetch.c 2009/02/05 23:29:14 1.18
+++ pkgsrc/net/libfetch/files/fetch.c 2009/08/11 20:48:06 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fetch.c,v 1.18 2009/02/05 23:29:14 joerg Exp $ */ 1/* $NetBSD: fetch.c,v 1.19 2009/08/11 20:48:06 joerg Exp $ */
2/*- 2/*-
3 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav 3 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
4 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> 4 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer 11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged. 12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -70,29 +70,27 @@ static struct fetcherr url_errlist[] = { @@ -70,29 +70,27 @@ static struct fetcherr url_errlist[] = {
70}; 70};
71 71
72 72
73/*** Public API **************************************************************/ 73/*** Public API **************************************************************/
74 74
75/* 75/*
76 * Select the appropriate protocol for the URL scheme, and return a 76 * Select the appropriate protocol for the URL scheme, and return a
77 * read-only stream connected to the document referenced by the URL. 77 * read-only stream connected to the document referenced by the URL.
78 * Also fill out the struct url_stat. 78 * Also fill out the struct url_stat.
79 */ 79 */
80fetchIO * 80fetchIO *
81fetchXGet(struct url *URL, struct url_stat *us, const char *flags) 81fetchXGet(struct url *URL, struct url_stat *us, const char *flags)
82{ 82{
83 int direct; 
84 83
85 direct = CHECK_FLAG('d'); 
86 if (us != NULL) { 84 if (us != NULL) {
87 us->size = -1; 85 us->size = -1;
88 us->atime = us->mtime = 0; 86 us->atime = us->mtime = 0;
89 } 87 }
90 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 88 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
91 return (fetchXGetFile(URL, us, flags)); 89 return (fetchXGetFile(URL, us, flags));
92 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 90 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
93 return (fetchXGetFTP(URL, us, flags)); 91 return (fetchXGetFTP(URL, us, flags));
94 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 92 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
95 return (fetchXGetHTTP(URL, us, flags)); 93 return (fetchXGetHTTP(URL, us, flags));
96 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 94 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
97 return (fetchXGetHTTP(URL, us, flags)); 95 return (fetchXGetHTTP(URL, us, flags));
98 url_seterr(URL_BAD_SCHEME); 96 url_seterr(URL_BAD_SCHEME);
@@ -106,78 +104,72 @@ fetchXGet(struct url *URL, struct url_st @@ -106,78 +104,72 @@ fetchXGet(struct url *URL, struct url_st
106fetchIO * 104fetchIO *
107fetchGet(struct url *URL, const char *flags) 105fetchGet(struct url *URL, const char *flags)
108{ 106{
109 return (fetchXGet(URL, NULL, flags)); 107 return (fetchXGet(URL, NULL, flags));
110} 108}
111 109
112/* 110/*
113 * Select the appropriate protocol for the URL scheme, and return a 111 * Select the appropriate protocol for the URL scheme, and return a
114 * write-only stream connected to the document referenced by the URL. 112 * write-only stream connected to the document referenced by the URL.
115 */ 113 */
116fetchIO * 114fetchIO *
117fetchPut(struct url *URL, const char *flags) 115fetchPut(struct url *URL, const char *flags)
118{ 116{
119 int direct; 
120 117
121 direct = CHECK_FLAG('d'); 
122 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 118 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
123 return (fetchPutFile(URL, flags)); 119 return (fetchPutFile(URL, flags));
124 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 120 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
125 return (fetchPutFTP(URL, flags)); 121 return (fetchPutFTP(URL, flags));
126 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 122 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
127 return (fetchPutHTTP(URL, flags)); 123 return (fetchPutHTTP(URL, flags));
128 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 124 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
129 return (fetchPutHTTP(URL, flags)); 125 return (fetchPutHTTP(URL, flags));
130 url_seterr(URL_BAD_SCHEME); 126 url_seterr(URL_BAD_SCHEME);
131 return (NULL); 127 return (NULL);
132} 128}
133 129
134/* 130/*
135 * Select the appropriate protocol for the URL scheme, and return the 131 * Select the appropriate protocol for the URL scheme, and return the
136 * size of the document referenced by the URL if it exists. 132 * size of the document referenced by the URL if it exists.
137 */ 133 */
138int 134int
139fetchStat(struct url *URL, struct url_stat *us, const char *flags) 135fetchStat(struct url *URL, struct url_stat *us, const char *flags)
140{ 136{
141 int direct; 
142 137
143 direct = CHECK_FLAG('d'); 
144 if (us != NULL) { 138 if (us != NULL) {
145 us->size = -1; 139 us->size = -1;
146 us->atime = us->mtime = 0; 140 us->atime = us->mtime = 0;
147 } 141 }
148 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 142 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
149 return (fetchStatFile(URL, us, flags)); 143 return (fetchStatFile(URL, us, flags));
150 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 144 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
151 return (fetchStatFTP(URL, us, flags)); 145 return (fetchStatFTP(URL, us, flags));
152 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 146 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
153 return (fetchStatHTTP(URL, us, flags)); 147 return (fetchStatHTTP(URL, us, flags));
154 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 148 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
155 return (fetchStatHTTP(URL, us, flags)); 149 return (fetchStatHTTP(URL, us, flags));
156 url_seterr(URL_BAD_SCHEME); 150 url_seterr(URL_BAD_SCHEME);
157 return (-1); 151 return (-1);
158} 152}
159 153
160/* 154/*
161 * Select the appropriate protocol for the URL scheme, and return a 155 * Select the appropriate protocol for the URL scheme, and return a
162 * list of files in the directory pointed to by the URL. 156 * list of files in the directory pointed to by the URL.
163 */ 157 */
164int 158int
165fetchList(struct url_list *ue, struct url *URL, const char *pattern, 159fetchList(struct url_list *ue, struct url *URL, const char *pattern,
166 const char *flags) 160 const char *flags)
167{ 161{
168 int direct; 
169 162
170 direct = CHECK_FLAG('d'); 
171 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) 163 if (strcasecmp(URL->scheme, SCHEME_FILE) == 0)
172 return (fetchListFile(ue, URL, pattern, flags)); 164 return (fetchListFile(ue, URL, pattern, flags));
173 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) 165 else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0)
174 return (fetchListFTP(ue, URL, pattern, flags)); 166 return (fetchListFTP(ue, URL, pattern, flags));
175 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) 167 else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0)
176 return (fetchListHTTP(ue, URL, pattern, flags)); 168 return (fetchListHTTP(ue, URL, pattern, flags));
177 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0) 169 else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
178 return (fetchListHTTP(ue, URL, pattern, flags)); 170 return (fetchListHTTP(ue, URL, pattern, flags));
179 url_seterr(URL_BAD_SCHEME); 171 url_seterr(URL_BAD_SCHEME);
180 return -1; 172 return -1;
181} 173}
182 174
183/* 175/*