From: Michael Wallner Date: Sun, 24 Jul 2005 10:30:45 +0000 (+0000) Subject: - fix some gcc warnings X-Git-Tag: RELEASE_0_10_0~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e6d4ae260275041fcc32f06f3487cdef6613c646;p=m6w6%2Fext-http - fix some gcc warnings --- diff --git a/KnownIssues.txt b/KnownIssues.txt index 1c9d41d..ae9efc7 100644 --- a/KnownIssues.txt +++ b/KnownIssues.txt @@ -4,4 +4,3 @@ $Id$ Issues I don't know how to solve yet are as follows: -There are random segfaults with PHP-5.1 and HttpRequestPool. diff --git a/config.m4 b/config.m4 index 2f8399c..3967b1f 100644 --- a/config.m4 +++ b/config.m4 @@ -79,6 +79,10 @@ dnl ---- PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, [$ext_shared]) PHP_SUBST([HTTP_SHARED_LIBADD]) PHP_ADD_MAKEFILE_FRAGMENT + if ! test -z "$HTTP_ODD_WARNINGS"; then + CFLAGS=" -g -O2 -W -Wchar-subscripts -Wformat=2 -Wno-format-y2k -Wimplicit -Wmissing-braces -Wunused-variable -Wbad-function-cast -Wpointer-arith -Wsign-compare -Winline" + PHP_SUBST([CFLAGS]) + fi AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support]) fi diff --git a/http_date_api.c b/http_date_api.c index c59b2cf..37047b6 100644 --- a/http_date_api.c +++ b/http_date_api.c @@ -132,7 +132,7 @@ static int check_month(char *month) static int check_tzone(char *tzone) { - int i; + unsigned i; const struct time_zone *check = time_zones; for (i = 0; i < sizeof(time_zones) / sizeof(time_zones[0]); i++) { if (!strcmp(tzone, check->name)) { @@ -175,7 +175,7 @@ PHP_HTTP_API time_t _http_parse_date(const char *date) enum assume_next dignext = DATE_MDAY; const char *indate = date; - int found = 0, part = 0; /* max 6 parts */ + int part = 0; /* max 6 parts */ while (*date && (part < 6)) { int found = 0; diff --git a/http_functions.c b/http_functions.c index a46d028..7eee100 100644 --- a/http_functions.c +++ b/http_functions.c @@ -689,7 +689,7 @@ PHP_FUNCTION(http_match_request_header) { char *header, *value; int header_len, value_len; - zend_bool match_case = 0, result = 0; + zend_bool match_case = 0; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &header, &header_len, &value, &value_len, &match_case)) { RETURN_FALSE; diff --git a/http_headers_api.c b/http_headers_api.c index f264b68..f59ba16 100644 --- a/http_headers_api.c +++ b/http_headers_api.c @@ -76,6 +76,7 @@ PHP_HTTP_API char *_http_negotiate_q(const char *entry, const HashTable *support } else { qual = 1000.0 - i++; } + /* TODO: support primaries only, too */ FOREACH_HASH_VAL((HashTable *)supported, zsupp) { if (!strcasecmp(Z_STRVAL_PP(zsupp), Z_STRVAL_PP(zentry))) { add_assoc_double(&zentries, Z_STRVAL_PP(zsupp), qual); @@ -111,7 +112,9 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ range = Z_STRVAL_P(zrange); if (strncmp(range, "bytes=", sizeof("bytes=") - 1)) { + /* should we really issue a notice for a client misbehaviour? http_error(E_NOTICE, HTTP_E_HEADER, "Range header misses bytes="); + */ return RANGE_NO; } @@ -169,7 +172,7 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ return RANGE_NO; } /* "0-0" or overflow */ - if (end == -10 || length <= end) { + if (end == -10 || length <= (size_t) end) { return RANGE_ERR; } begin = 0; @@ -178,7 +181,7 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ /* "-12345" */ case -1: /* "-", "-0" or overflow */ - if (end == -1 || end == -10 || length <= end) { + if (end == -1 || end == -10 || length <= (size_t) end) { return RANGE_ERR; } begin = length - end; @@ -196,7 +199,7 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ /* "12345-" */ case -1: - if (length <= begin) { + if (length <= (size_t) begin) { return RANGE_ERR; } end = length - 1; @@ -204,8 +207,8 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ /* "12345-67890" */ default: - if ( (length <= begin) || - (length <= end) || + if ( (length <= (size_t) begin) || + (length <= (size_t) end) || (end < begin)) { return RANGE_ERR; } @@ -261,7 +264,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header line = header; - while (header_len >= (line - begin)) { + while (header_len >= (size_t) (line - begin)) { int value_len = 0; switch (*line++) diff --git a/http_message_api.c b/http_message_api.c index 1cf8661..b119464 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -190,7 +190,7 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char zval *len; char *tmp; - spprintf(&tmp, 0, "%lu", decoded_len); + spprintf(&tmp, 0, "%lu", (ulong) decoded_len); MAKE_STD_ZVAL(len); ZVAL_STRING(len, tmp, 0); diff --git a/http_message_object.c b/http_message_object.c index 8cf6969..027cbdf 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -165,7 +165,7 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message ALLOC_HASHTABLE(OBJ_PROP(o)); zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); - ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_message_object_free, NULL TSRMLS_CC); + ov.handle = putObject(http_message_object, o); ov.handlers = &http_message_object_handlers; return ov; @@ -332,7 +332,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va { case HTTP_MSG_PROPHASH_TYPE: convert_to_long_ex(&value); - if (Z_LVAL_P(value) != msg->type) { + if ((http_message_type) Z_LVAL_P(value) != msg->type) { if (HTTP_MSG_TYPE(REQUEST, msg)) { if (msg->info.request.method) { efree(msg->info.request.method); diff --git a/http_request_api.c b/http_request_api.c index a83cacf..b8173bc 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -968,7 +968,7 @@ static inline zval *_http_curl_getopt_ex(HashTable *options, char *key, size_t k case IS_DOUBLE: convert_to_double_ex(zoption); break; case IS_STRING: convert_to_string_ex(zoption); break; case IS_ARRAY: convert_to_array_ex(zoption); break; - case IS_OBJECT: convert_to_object_ex(zoption); break; + case IS_OBJECT: convert_to_object_ex(zoption); break; default: break; } diff --git a/http_request_object.c b/http_request_object.c index 4d86227..534b099 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -337,7 +337,7 @@ zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC) zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_request_object_free, NULL TSRMLS_CC); + ov.handle = putObject(http_request_object, o); ov.handlers = &http_request_object_handlers; return ov; @@ -1545,7 +1545,7 @@ PHP_METHOD(HttpRequest, getResponseMessage) PHP_METHOD(HttpRequest, send) { STATUS status = FAILURE; - http_request_body body = {0}; + http_request_body body = {0, NULL, 0}; getObject(http_request_object, obj); NO_ARGS; diff --git a/http_request_pool_api.c b/http_request_pool_api.c index b62eeea..c9e5278 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -80,7 +80,6 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req http_error_ex(E_WARNING, HTTP_E_CURL, "HttpRequest object(#%d) is already member of %s HttpRequestPool", Z_OBJ_HANDLE_P(request), req->pool == pool ? "this" : "another"); } else { http_request_body *body = http_request_body_new(); - zval *info = GET_PROP_EX(req, request, responseInfo); if (SUCCESS != http_request_object_requesthandler(req, request, body)) { http_error_ex(E_WARNING, HTTP_E_CURL, "Could not initialize HttpRequest object for attaching to the HttpRequestPool"); diff --git a/http_requestpool_object.c b/http_requestpool_object.c index 5323342..c940f71 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -116,7 +116,7 @@ zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC) zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_requestpool_object_free, NULL TSRMLS_CC); + ov.handle = putObject(http_requestpool_object, o); ov.handlers = &http_requestpool_object_handlers; return ov; diff --git a/http_send_api.c b/http_send_api.c index 023c6ec..b89102d 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -279,7 +279,7 @@ PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_ http_send_status(206); /* send content range header */ - snprintf(range_header, 255, "Content-Range: bytes %d-%d/%d", **begin, **end, size); + snprintf(range_header, 255, "Content-Range: bytes %ld-%ld/%lu", **begin, **end, (ulong) size); http_send_header(range_header); /* send requested chunk */ @@ -295,7 +295,7 @@ PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_ http_send_status(206); /* send multipart/byteranges header */ - snprintf(bound, 22, "--%d%0.9f", time(NULL), php_combined_lcg(TSRMLS_C)); + snprintf(bound, 22, "--%lu%0.9f", (ulong) time(NULL), php_combined_lcg(TSRMLS_C)); strncat(multi_header, bound + 2, 21); http_send_header(multi_header); @@ -309,7 +309,7 @@ PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_ snprintf(preface, 1023, HTTP_CRLF "%s" HTTP_CRLF "Content-Type: %s" - HTTP_CRLF "Content-Range: bytes %ld-%ld/%ld" + HTTP_CRLF "Content-Range: bytes %ld-%ld/%lu" HTTP_CRLF HTTP_CRLF, @@ -317,7 +317,7 @@ PHP_HTTP_API STATUS _http_send_ranges(HashTable *ranges, const void *data, size_ HTTP_G(send).content_type ? HTTP_G(send).content_type : "application/x-octetstream", **begin, **end, - size + (ulong) size ); PHPWRITE(preface, strlen(preface)); diff --git a/http_url_api.c b/http_url_api.c index b32fd9d..64bc6bd 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -50,7 +50,7 @@ PHP_HTTP_API char *_http_absolute_url_ex( #if defined(PHP_WIN32) || defined(HAVE_NETDB_H) struct servent *se; #endif - php_url *purl, furl = {NULL}; + php_url *purl = NULL, furl; size_t full_len = 0; zval *zhost = NULL; char *scheme = NULL, *uri, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 65c72c1..dce34fa 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -193,6 +193,7 @@ typedef int STATUS; # define getObject(t, o) getObjectEx(t, o, getThis()) # define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC)) +# define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) t## _free, NULL TSRMLS_CC); # define OBJ_PROP(o) (o)->zo.properties # define DCL_STATIC_PROP(a, t, n, v) zend_declare_property_ ##t(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC) # define DCL_STATIC_PROP_Z(a, n, v) zend_declare_property(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)