You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "William A. Rowe, Jr." <wr...@covalent.net> on 2002/03/08 05:42:56 UTC
1.3.24-dev new warning...
C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
: warning C4018: '<' : signed/unsigned mismatch
n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
Whoever is hacking in proxy, feel free to correct.
[The only other emits according to win32 are FD_SET obscurity.]
Bill
Re: 1.3.24-dev new warning...
Posted by Chuck Murcko <ch...@topsail.org>.
There are two other places in mod_proxy the MIN macro gets used.
Shouldn't those get cast to the desired return type as well?
This one's a time_t:
proxy_cache.c line 1175 maxage = MIN(maxage_req, maxage_cresp);
and this one's a size_t:
proxy_util.c line 734 strncpy(valbuf, list, MIN(p-list,
sizeof(valbuf)-1));
Chuck
On Friday, April 19, 2002, at 02:07 PM, William A. Rowe, Jr. wrote:
> At 10:03 AM 3/19/2002, you wrote:
>> At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>> >C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
>> > : warning C4018: '<' : signed/unsigned mismatch
>> >
>> > n = ap_bread(f, buf, MIN(buf_size, len -
>> total_bytes_rcvd));
>>
>> I had posted a patch regarding this a bit ago... Any feedback? I was
>> not able to recreate the exact error messages locally on any of
>> my machines, so I couldn't see if it solved the specific problem
>> (without creating more :) ).
>
> Doh! MIN() is implemented in terms of a terniary, and those are very
> broken in terms of the result type on win32. Casting the MIN() back to
> the arg type of ap_bread() should be sufficient.
>
>
Re: 1.3.24-dev new warning...
Posted by Greg Marr <gr...@alum.wpi.edu>.
At 01:07 PM 04/19/2002, William A. Rowe, Jr. wrote:
>At 10:03 AM 3/19/2002, you wrote:
>>At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>> >C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
>> > : warning C4018: '<' : signed/unsigned mismatch
>> >
>> > n = ap_bread(f, buf, MIN(buf_size, len -
>> total_bytes_rcvd));
>>
>>I had posted a patch regarding this a bit ago... Any feedback? I was
>>not able to recreate the exact error messages locally on any of
>>my machines, so I couldn't see if it solved the specific problem
>>(without creating more :) ).
>
>Doh! MIN() is implemented in terms of a terniary, and those are very
>broken in terms of the result type on win32. Casting the MIN() back
>to
>the arg type of ap_bread() should be sufficient.
I doubt it. The warning is about the '<', which occurs because
buf_size is size_t, and len is off_t.
BTW, I've never had any troubles with the result type of ?: on
Win32. It's always the result type of the true result, which is what
it should be, as far as I've seen. Could you be a bit more specific?
--
Greg Marr
gregm@alum.wpi.edu
"We thought you were dead."
"I was, but I'm better now." - Sheridan, "The Summoning"
Re: 1.3.24-dev new warning...
Posted by Chuck Murcko <ch...@topsail.org>.
OK, I'll fix and commit this tonight.
Chuck
On Friday, April 19, 2002, at 02:07 PM, William A. Rowe, Jr. wrote:
> At 10:03 AM 3/19/2002, you wrote:
>> At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>> >C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
>> > : warning C4018: '<' : signed/unsigned mismatch
>> >
>> > n = ap_bread(f, buf, MIN(buf_size, len -
>> total_bytes_rcvd));
>>
>> I had posted a patch regarding this a bit ago... Any feedback? I was
>> not able to recreate the exact error messages locally on any of
>> my machines, so I couldn't see if it solved the specific problem
>> (without creating more :) ).
>
> Doh! MIN() is implemented in terms of a terniary, and those are very
> broken in terms of the result type on win32. Casting the MIN() back to
> the arg type of ap_bread() should be sufficient.
>
>
Re: 1.3.24-dev new warning...
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 10:03 AM 3/19/2002, you wrote:
>At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
> >C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
> > : warning C4018: '<' : signed/unsigned mismatch
> >
> > n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
>
>I had posted a patch regarding this a bit ago... Any feedback? I was
>not able to recreate the exact error messages locally on any of
>my machines, so I couldn't see if it solved the specific problem
>(without creating more :) ).
Doh! MIN() is implemented in terms of a terniary, and those are very
broken in terms of the result type on win32. Casting the MIN() back to
the arg type of ap_bread() should be sufficient.
Re: 1.3.24-dev new warning...
Posted by Jim Jagielski <ji...@jaguNET.com>.
At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
> : warning C4018: '<' : signed/unsigned mismatch
>
> n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
>
>Whoever is hacking in proxy, feel free to correct.
>
>[The only other emits according to win32 are FD_SET obscurity.]
>
>Bill
I had posted a patch regarding this a bit ago... Any feedback? I was
not able to recreate the exact error messages locally on any of
my machines, so I couldn't see if it solved the specific problem
(without creating more :) ).
--
===========================================================================
Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/
"A society that will trade a little liberty for a little order
will lose both and deserve neither" - T.Jefferson
Re: 1.3.24-dev new warning...
Posted by Jim Jagielski <ji...@jaguNET.com>.
At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
> : warning C4018: '<' : signed/unsigned mismatch
>
> n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
>
>Whoever is hacking in proxy, feel free to correct.
>
>[The only other emits according to win32 are FD_SET obscurity.]
>
>Bill
Hmmm... I don't see this. No doubt it's a size_t/off_t issue and
whether (for example) one might be an unsigned long and the other
a signed quad. Hmm. We do some widest int calcs in ap_snprintf. Maybe it
would make sense to move that knowledge to a header file for use by
other code. Then we could then use casts for the above...
--
===========================================================================
Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/
"A society that will trade a little liberty for a little order
will lose both and deserve neither" - T.Jefferson
Re: 1.3.24-dev new warning...
Posted by Jim Jagielski <ji...@jaguNET.com>.
At 10:42 PM -0600 3/7/02, William A. Rowe, Jr. wrote:
>C:\clean\apache-1.3\src\modules\proxy\proxy_util.c(565)
> : warning C4018: '<' : signed/unsigned mismatch
>
> n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
>
>Whoever is hacking in proxy, feel free to correct.
>
>[The only other emits according to win32 are FD_SET obscurity.]
>
Try this:
Index: src/ap/ap_snprintf.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/ap/ap_snprintf.c,v
retrieving revision 1.49
diff -u -r1.49 ap_snprintf.c
--- src/ap/ap_snprintf.c 21 Jan 2002 21:56:43 -0000 1.49
+++ src/ap/ap_snprintf.c 8 Mar 2002 15:09:31 -0000
@@ -87,22 +87,9 @@
#ifndef TRUE
#define TRUE 1
#endif
-#ifndef AP_LONGEST_LONG
-#define AP_LONGEST_LONG long
-#endif
+
#define NUL '\0'
-#define WIDE_INT long
-#define WIDEST_INT AP_LONGEST_LONG
-typedef WIDE_INT wide_int;
-typedef unsigned WIDE_INT u_wide_int;
-typedef WIDEST_INT widest_int;
-#ifdef __TANDEM
-/* Although Tandem supports "long long" there is no unsigned variant. */
-typedef unsigned long u_widest_int;
-#else
-typedef unsigned WIDEST_INT u_widest_int;
-#endif
typedef int bool_int;
#define S_NULL "(null)"
Index: src/include/ap.h
===================================================================
RCS file: /home/cvs/apache-1.3/src/include/ap.h,v
retrieving revision 1.32
diff -u -r1.32 ap.h
--- src/include/ap.h 21 Jan 2002 21:56:43 -0000 1.32
+++ src/include/ap.h 8 Mar 2002 15:09:31 -0000
@@ -141,6 +141,26 @@
char *endpos;
} ap_vformatter_buff;
+/*
+ * Figure out the widest integer values available, in
+ * both signed and unsigned variety. Most in use by
+ * ap_snprintf() but useful for others as well
+ */
+#ifndef AP_LONGEST_LONG
+#define AP_LONGEST_LONG long
+#endif
+#define WIDE_INT long
+#define WIDEST_INT AP_LONGEST_LONG
+typedef WIDE_INT wide_int;
+typedef unsigned WIDE_INT u_wide_int;
+typedef WIDEST_INT widest_int;
+#ifdef __TANDEM
+/* Although Tandem supports "long long" there is no unsigned variant. */
+typedef unsigned long u_widest_int;
+#else
+typedef unsigned WIDEST_INT u_widest_int;
+#endif
+
API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *),
ap_vformatter_buff *, const char *fmt, va_list ap);
Index: src/modules/proxy/proxy_util.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
retrieving revision 1.106
diff -u -r1.106 proxy_util.c
--- src/modules/proxy/proxy_util.c 26 Feb 2002 18:01:28 -0000 1.106
+++ src/modules/proxy/proxy_util.c 8 Mar 2002 15:09:34 -0000
@@ -562,7 +562,8 @@
n = ap_bread(f, buf, buf_size);
}
else {
- n = ap_bread(f, buf, MIN(buf_size, len - total_bytes_rcvd));
+ n = ap_bread(f, buf,
+ MIN((u_widest_int)buf_size, (u_widest_int)(len - total_bytes_rcvd)));
}
if (alternate_timeouts)
--
===========================================================================
Jim Jagielski [|] jim@jaguNET.com [|] http://www.jaguNET.com/
"A society that will trade a little liberty for a little order
will lose both and deserve neither" - T.Jefferson