- fix some gcc warnings
authorMichael Wallner <mike@php.net>
Sun, 24 Jul 2005 10:30:45 +0000 (10:30 +0000)
committerMichael Wallner <mike@php.net>
Sun, 24 Jul 2005 10:30:45 +0000 (10:30 +0000)
14 files changed:
KnownIssues.txt
config.m4
http_date_api.c
http_functions.c
http_headers_api.c
http_message_api.c
http_message_object.c
http_request_api.c
http_request_object.c
http_request_pool_api.c
http_requestpool_object.c
http_send_api.c
http_url_api.c
php_http_std_defs.h

index 1c9d41da28051da6e7c300fb65838b141929f011..ae9efc715127c562180eee9ce8240b3c08dedf2f 100644 (file)
@@ -4,4 +4,3 @@ $Id$
 
 Issues I don't know how to solve yet are as follows:
 
 
 Issues I don't know how to solve yet are as follows:
 
-There are random segfaults with PHP-5.1 and HttpRequestPool.
index 2f8399cfd387c0bb65d6de838a15d54d7147bdf2..3967b1fe15b37ce9629874d0a6ce96690f937d5b 100644 (file)
--- 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
        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
 
        AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
 fi
 
index c59b2cfe4c00e172ec1cfa3af93c73b75f27748d..37047b602326187ecd20770609c158f58a7b8f71 100644 (file)
@@ -132,7 +132,7 @@ static int check_month(char *month)
 
 static int check_tzone(char *tzone)
 {
 
 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)) {
        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;
 
        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;
 
        while (*date && (part < 6)) {
                int found = 0;
index a46d02883b1dc9bc5d2487bc9a54c4ee2a020b06..7eee1007ebf3e42300482978b81d568fea6f7c69 100644 (file)
@@ -689,7 +689,7 @@ PHP_FUNCTION(http_match_request_header)
 {
        char *header, *value;
        int header_len, value_len;
 {
        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;
 
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &header, &header_len, &value, &value_len, &match_case)) {
                RETURN_FALSE;
index f264b68ae4c4ccd1771b2cc289869e959cd28eb5..f59ba164c9c73159767023838c119e6fffea128a 100644 (file)
@@ -76,6 +76,7 @@ PHP_HTTP_API char *_http_negotiate_q(const char *entry, const HashTable *support
                } else {
                        qual = 1000.0 - i++;
                }
                } 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);
                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)) {
        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=");
                http_error(E_NOTICE, HTTP_E_HEADER, "Range header misses bytes=");
+               */
                return RANGE_NO;
        }
 
                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 */
                                                                return RANGE_NO;
                                                        }
                                                        /* "0-0" or overflow */
-                                                       if (end == -10 || length <= end) {
+                                                       if (end == -10 || length <= (size_t) end) {
                                                                return RANGE_ERR;
                                                        }
                                                        begin = 0;
                                                                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 */
                                                /* "-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;
                                                                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:
 
                                                                /* "12345-" */
                                                                case -1:
-                                                                       if (length <= begin) {
+                                                                       if (length <= (size_t) begin) {
                                                                                return RANGE_ERR;
                                                                        }
                                                                        end = length - 1;
                                                                                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:
 
                                                                /* "12345-67890" */
                                                                default:
-                                                                       if (    (length <= begin) ||
-                                                                                       (length <= end)   ||
+                                                                       if (    (length <= (size_t) begin) ||
+                                                                                       (length <= (size_t) end)   ||
                                                                                        (end    <  begin)) {
                                                                                return RANGE_ERR;
                                                                        }
                                                                                        (end    <  begin)) {
                                                                                return RANGE_ERR;
                                                                        }
@@ -261,7 +264,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
 
        line = header;
 
 
        line = header;
 
-       while (header_len >= (line - begin)) {
+       while (header_len >= (size_t) (line - begin)) {
                int value_len = 0;
 
                switch (*line++)
                int value_len = 0;
 
                switch (*line++)
index 1cf8661546574505b5d3d1dd255713c585c2b058..b1194645ecc87caae8d33ab0f68e866e7fb1d0be 100644 (file)
@@ -190,7 +190,7 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char
                                                zval *len;
                                                char *tmp;
 
                                                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);
 
                                                MAKE_STD_ZVAL(len);
                                                ZVAL_STRING(len, tmp, 0);
 
index 8cf6969a885bf9003f610353baa1b764df852a60..027cbdfcd5c7ad221b09911f2ba0ff45746d900b 100644 (file)
@@ -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);
 
        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;
        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);
        {
                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);
                                if (HTTP_MSG_TYPE(REQUEST, msg)) {
                                        if (msg->info.request.method) {
                                                efree(msg->info.request.method);
index a83cacfa6da3f0666d8890e1fc505414b15f5c19..b8173bc5ef7060190b1c3aed794393ba1c837ab3 100644 (file)
@@ -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_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;
                }
                        default:
                        break;
                }
index 4d862279e0807a13b05cb45cea093fc2bad16902..534b09942bec8c397365d3d54a08c50996ee137b 100644 (file)
@@ -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 *));
 
        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;
        ov.handlers = &http_request_object_handlers;
 
        return ov;
@@ -1545,7 +1545,7 @@ PHP_METHOD(HttpRequest, getResponseMessage)
 PHP_METHOD(HttpRequest, send)
 {
        STATUS status = FAILURE;
 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;
        getObject(http_request_object, obj);
 
        NO_ARGS;
index b62eeea7674bcb8603b9e791fd24823031b99b86..c9e5278f1ad2b6ec50871429c3317d97fb5b3027 100644 (file)
@@ -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();
                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");
 
                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");
index 53233429cfcaa5b44e0cc760c9976c45534c3fe6..c940f71107400f9e868db35b9041ca216f07b302 100644 (file)
@@ -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 *));
 
        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;
        ov.handlers = &http_requestpool_object_handlers;
 
        return ov;
index 023c6ecb4398f78b390574a034b3388bfcb220df..b89102d473be15fe5ecf0aff69f83e6395d7c765 100644 (file)
@@ -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 */
                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 */
                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 */
                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);
 
                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"
                        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,
 
                                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,
                                HTTP_G(send).content_type ? HTTP_G(send).content_type : "application/x-octetstream",
                                **begin,
                                **end,
-                               size
+                               (ulong) size
                        );
 
                        PHPWRITE(preface, strlen(preface));
                        );
 
                        PHPWRITE(preface, strlen(preface));
index b32fd9d454758e44191b05bf2114213e51406c7c..64bc6bd08481a2f962ae9e96135e260bbe0394ad 100644 (file)
@@ -50,7 +50,7 @@ PHP_HTTP_API char *_http_absolute_url_ex(
 #if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
        struct servent *se;
 #endif
 #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);
        size_t full_len = 0;
        zval *zhost = NULL;
        char *scheme = NULL, *uri, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1);
index 65c72c1f42ac2c8aa9078777295ee511284c5cbf..dce34fa79bb86380d4ccd13f2c05dfaaabd2d7e5 100644 (file)
@@ -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 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)
 #      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)