Hi Jim,

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1501848&r1=1501847&r2=1501848&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Wed Jul 10 16:53:22 2013
@@ -221,6 +221,10 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK:
                  http://svn.apache.org/r1500519
     2.4.x patch: trunk patches work
     +1: fuankg
+    comments:
+          jj: In general, casts are sometimes used to "hide" problems
+              that exist, esp when using the incorrect data types...
+              Are these casts safe?

I think I did my best to not hide problems but instead tried to use the right data types where ever possible ...

* fixed data type *
Index: modules/filters/mod_charset_lite.c
===================================================================
--- modules/filters/mod_charset_lite.c  (revision 1500344)
+++ modules/filters/mod_charset_lite.c  (revision 1500345)
@@ -474,7 +474,7 @@
     charset_filter_ctx_t *ctx = f->ctx;
     const char *msg;
     char msgbuf[100];
-    int len;
+    apr_size_t len;

     switch(ctx->ees) {
     case EES_LIMIT:

* AFAIK lua has only 2 datatypes int and double, so this cast is required *
Index: modules/lua/lua_request.c
===================================================================
--- modules/lua/lua_request.c   (revision 1500361)
+++ modules/lua/lua_request.c   (revision 1500362)
@@ -884,7 +884,7 @@
     r = ap_lua_check_request_rec(L, 1);
     luaL_checktype(L, 2, LUA_TSTRING);
     path = lua_tostring(L, 2);
-    mtime = luaL_optnumber(L, 3, apr_time_now());
+    mtime = (apr_time_t)luaL_optnumber(L, 3, (lua_Number)apr_time_now());
     status = apr_file_mtime_set(path, mtime, r->pool);
     lua_pushboolean(L, (status == 0));
     return 1;

* fixed data type *
Index: modules/cache/mod_socache_memcache.c
===================================================================
--- modules/cache/mod_socache_memcache.c        (revision 1500361)
+++ modules/cache/mod_socache_memcache.c        (revision 1500362)
@@ -85,7 +85,7 @@
 {
     apr_status_t rv;
     int thread_limit = 0;
-    int nservers = 0;
+    apr_uint16_t nservers = 0;
     char *cache_config;
     char *split;
     char *tok;

* this cast is needed because the expression is int but the function sig is char; as you can see 2 lines above ap_rputc() doesnt need this because it takes an int argument and does then self cast ... *
Index: modules/generators/mod_info.c
===================================================================
--- modules/generators/mod_info.c       (revision 1500361)
+++ modules/generators/mod_info.c       (revision 1500362)
@@ -113,7 +113,7 @@
         if (r)
             ap_rputc('0' + i % 10, r);
         else
-            apr_file_putc('0' + i % 10, out);
+            apr_file_putc((char)('0' + i % 10), out);
     }
     else {
         if (r)

* fixed data type *
Index: modules/proxy/mod_proxy_connect.c
===================================================================
--- modules/proxy/mod_proxy_connect.c   (revision 1500422)
+++ modules/proxy/mod_proxy_connect.c   (revision 1500423)
@@ -220,7 +220,7 @@

     apr_uri_t uri;
     const char *connectname;
-    int connectport = 0;
+    apr_port_t connectport = 0;

     /* is this for us? */
     if (r->method_number != M_CONNECT) {

* fixed data type where possible; if the cast to bodylen is wrong then the signature of fill_in_header() is wrong and should take apr_size_t instead *
Index: modules/proxy/mod_proxy_fcgi.c
===================================================================
--- modules/proxy/mod_proxy_fcgi.c      (revision 1500422)
+++ modules/proxy/mod_proxy_fcgi.c      (revision 1500423)
@@ -234,7 +234,8 @@
     return rv;
 }

-static apr_status_t send_begin_request(proxy_conn_rec *conn, int request_id)
+static apr_status_t send_begin_request(proxy_conn_rec *conn,
+                                       apr_uint16_t request_id)
 {
     struct iovec vec[2];
     fcgi_header header;
@@ -266,7 +267,7 @@
 }

 static apr_status_t send_environment(proxy_conn_rec *conn, request_rec *r,
-                                     int request_id)
+                                     apr_uint16_t request_id)
 {
     const apr_array_header_t *envarr;
     const apr_table_entry_t *elts;
@@ -390,7 +391,7 @@
         itr += vallen;
     }

-    fill_in_header(&header, FCGI_PARAMS, request_id, bodylen, 0);
+ fill_in_header(&header, FCGI_PARAMS, request_id, (apr_uint16_t)bodylen, 0);
     fcgi_header_to_array(&header, farray);

     vec[0].iov_base = (void *)farray;
@@ -543,7 +544,7 @@
 }

 static apr_status_t dispatch(proxy_conn_rec *conn, proxy_dir_conf *conf,
-                             request_rec *r, int request_id)
+                             request_rec *r, apr_uint16_t request_id)
 {
     apr_bucket_brigade *ib, *ob;
     int seen_end_of_headers = 0, done = 0;
@@ -884,7 +885,7 @@
      * multiple requests to the same FastCGI connection, but
      * we don't support that, and always use a value of '1' to
      * keep things simple. */
-    int request_id = 1;
+    apr_uint16_t request_id = 1;
     apr_status_t rv;

     /* Step 1: Send FCGI_BEGIN_REQUEST */

* fixed data type *
Index: include/util_ldap.h
===================================================================
--- include/util_ldap.h (revision 1500482)
+++ include/util_ldap.h (revision 1500483)
@@ -83,6 +83,10 @@
 #define LDAP_DECLARE_DATA             __declspec(dllimport)
 #endif

+#ifdef WIN32
+#define timeval l_timeval
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif

* cast to int due to sig of apr_base64_encode_len((int)),
 seems safe to me since clen is before tested for < APR_INT32_MAX *
Index: modules/filters/mod_data.c
===================================================================
--- modules/filters/mod_data.c  (revision 1500518)
+++ modules/filters/mod_data.c  (revision 1500519)
@@ -109,7 +109,8 @@
             apr_brigade_length(ctx->bb, 1, &len);
             clen = apr_atoi64(content_length);
             if (clen >= 0 && clen < APR_INT32_MAX) {
- ap_set_content_length(r, len + apr_base64_encode_len(clen) - 1);
+                ap_set_content_length(r, len +
+ apr_base64_encode_len((int)clen) - 1);
             }
             else {
                 apr_table_unset(r->headers_out, "Content-Length");


then I'm also asking me from whom to hide things? The warnings were there for a long time, and it seems that most folks here dont use maintainer mode, disable signed-unsigned warnings, and what else ... and if someone posts about warnings from pickier compilers like MSVC it gets most likely ignored here on the list ...

another mod which I didnt touch yet is mod_cache_socache where also wrong data types are used, and most likely you dont even see these probs when compiling for 64 bit because there apr_off_t and apr_size_t are both 64bit - but with 32 bit targets it happens that apr_size_t is only 32bit while apr_off_t is still 64bit when LARGE_FILES is anabled ... IIRC this mod is mainly Graham's babe, so any hints from him appreciated what's the 'right' way to fix those warnings ...

--------------------Configuration: mod_cache_socache - Win32 Release--------------------
Compiling resources...
Compiling...
mod_cache_socache.c
E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(399) : warning C4244: '=' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(400) : warning C4244: 'function' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(401) : warning C4244: 'function' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(464) : warning C4244: 'function' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(465) : warning C4244: '=' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(808) : warning C4244: 'function' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(809) : warning C4244: '=' : conversion from '__int64 ' to 'unsigned int ', possible loss of data E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(402) : warning C4761: integral size mismatch in argument; conversion supplied E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(402) : warning C4761: integral size mismatch in argument; conversion supplied E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(464) : warning C4761: integral size mismatch in argument; conversion supplied E:\projects\msvc\bldhttpd\build\httpd\modules\cache\mod_cache_socache.c(808) : warning C4761: integral size mismatch in argument; conversion supplied
Linking...
Creating library Release/mod_cache_socache.lib and object Release/mod_cache_socache.exp
Embed .manifest


A guy is sitting on the couch and coding some program while smoking one cigarette after another. His girlfriend doesnt like the smoke and says "Hey, don't you know that those things can kill you? Didn't you read the giant warning on the box?!" "That's OK," says the guy, puffing casually, "You know I'm a computer programmer."
"So? What's that got to do with anything?"
"We don't care about warnings. We only care about errors."

(sorry, couldnt resist to joke a bit :-P )

Gün.

Reply via email to