- 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 1c9d41d..ae9efc7 100644 (file)
@@ -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.
index 2f8399c..3967b1f 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
+       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
 
index c59b2cf..37047b6 100644 (file)
@@ -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;
index a46d028..7eee100 100644 (file)
@@ -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;
index f264b68..f59ba16 100644 (file)
@@ -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++)
index 1cf8661..b119464 100644 (file)
@@ -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);
 
index 8cf6969..027cbdf 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);
 
-       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);
index a83cacf..b8173bc 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_OBJECT: convert_to_object_ex(zoption);  break;
+                       case IS_OBJECT: convert_to_object_ex(zoption);  break;
                        default:
                        break;
                }
index 4d86227..534b099 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 *));
 
-       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;
index b62eeea..c9e5278 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();
-               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");
index 5323342..c940f71 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 *));
 
-       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;
index 023c6ec..b89102d 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 */
-               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));
index b32fd9d..64bc6bd 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
-       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);
index 65c72c1..dce34fa 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 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)