comparison src/protocols/gg/lib/http.c @ 12218:9cbc5967fbfd

[gaim-migrate @ 14520] Crush some warnings. I ran this by Bartosz Oler and made some corrections at his suggestion. I'll be submitting this upstream and merging any changes they suggest/make-when-accepting. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 25 Nov 2005 00:32:45 +0000
parents 3c536224f0d0
children
comparison
equal deleted inserted replaced
12217:029802981b81 12218:9cbc5967fbfd
1 /* $Id: http.c 13801 2005-09-14 19:10:39Z datallah $ */ 1 /* $Id: http.c 14520 2005-11-25 00:32:45Z rlaager $ */
2 2
3 /* 3 /*
4 * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl> 4 * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
235 return 0; 235 return 0;
236 } 236 }
237 237
238 if (h->state == GG_STATE_CONNECTING) { 238 if (h->state == GG_STATE_CONNECTING) {
239 int res = 0; 239 int res = 0;
240 unsigned int res_size = sizeof(res); 240 socklen_t res_size = sizeof(res);
241 241
242 if (h->async && (getsockopt(h->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res)) { 242 if (h->async && (getsockopt(h->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res)) {
243 gg_debug(GG_DEBUG_MISC, "=> http, async connection failed (errno=%d, %s)\n", (res) ? res : errno , strerror((res) ? res : errno)); 243 gg_debug(GG_DEBUG_MISC, "=> http, async connection failed (errno=%d, %s)\n", (res) ? res : errno , strerror((res) ? res : errno));
244 close(h->fd); 244 close(h->fd);
245 h->fd = -1; 245 h->fd = -1;
254 254
255 h->state = GG_STATE_SENDING_QUERY; 255 h->state = GG_STATE_SENDING_QUERY;
256 } 256 }
257 257
258 if (h->state == GG_STATE_SENDING_QUERY) { 258 if (h->state == GG_STATE_SENDING_QUERY) {
259 int res; 259 ssize_t res;
260 260
261 if ((res = write(h->fd, h->query, strlen(h->query))) < 1) { 261 if ((res = write(h->fd, h->query, strlen(h->query))) < 1) {
262 gg_debug(GG_DEBUG_MISC, "=> http, write() failed (len=%d, res=%d, errno=%d)\n", strlen(h->query), res, errno); 262 gg_debug(GG_DEBUG_MISC, "=> http, write() failed (len=%d, res=%d, errno=%d)\n", strlen(h->query), res, errno);
263 gg_http_error(GG_ERROR_WRITING); 263 gg_http_error(GG_ERROR_WRITING);
264 } 264 }
265 265
266 if (res < strlen(h->query)) { 266 if (res < 0 || (size_t)res < strlen(h->query)) {
267 gg_debug(GG_DEBUG_MISC, "=> http, partial header sent (led=%d, sent=%d)\n", strlen(h->query), res); 267 gg_debug(GG_DEBUG_MISC, "=> http, partial header sent (led=%d, sent=%d)\n", strlen(h->query), res);
268 268
269 memmove(h->query, h->query + res, strlen(h->query) - res + 1); 269 memmove(h->query, h->query + res, strlen(h->query) - res + 1);
270 h->state = GG_STATE_SENDING_QUERY; 270 h->state = GG_STATE_SENDING_QUERY;
271 h->check = GG_CHECK_WRITE; 271 h->check = GG_CHECK_WRITE;