I'd like to point you to this comment in Makefile.flags:
# FIXME: These warnings are at least partially to be concerned about and
# should be fixed..
#CFLAGS += $(call cc-option,-Wconversion,)
I just removed the '#' in front of CFLAGS and found myself staring at
some 131 conversion warnings in shell/ash.c only:
27 'size_t' from 'int' may change the sign of the result
24 'char' from 'int' may alter its value
15 'smallint' from 'int' may alter its value
15 'unsigned int' from 'int' may change the sign of the result
13 'uint8_t' from 'int' may alter its value
10 'int' from 'unsigned int' may change the sign of the result
8 'int' from 'size_t' may change the sign of the result
3 'int32_t' from 'uint32_t' may change the sign of the result
2 'size_t' from 'ssize_t' may change the sign of the result
2 'ssize_t' from 'size_t' may change the sign of the result
2 'uint32_t' from 'int' may change the sign of the result
1 'cc_t' from 'int' may alter its value
1 'long long unsigned int' from 'int' may change the sign of the result
1 'mode_t' from 'int' may change the sign of the result
1 'rlim_t' from 'long int' may change the sign of the result
1 'token_id_t' from 'char' may change the sign of the result
1 'token_id_t' from 'int' may alter its value
1 'uint32_t' from 'int32_t' may change the sign of the result
1 'uint32_t' from 'long long unsigned int' may alter its value
1 'unsigned char' from 'int' may alter its value
1 'unsigned int' from 'pid_t' may change the sign of the result
I thought it might be a good idea to initiate a discussion around the
subject, and try to find a way to correct this. Maybe that was a not
such a good idea.
On Sun, 11 Oct 2009, Denys Vlasenko wrote:
>
> Cristian, size_t is 64-bit on x86-64.
Well, you are probably refering to modifications like this one:
- int i = strlen(str->text);
+ size_t i = strlen(str->text);
But 'i' must obviously be some unsigned type, shouldn't it?
What's the gain of using 'int' vs. 'size_t'?
> Using size_t for strlen and such bloats code.
size_t _should be used_ for strlen. It's documented. There's a man
page:
SYNOPSIS
#include <string.h>
size_t strlen(const char *s);
It has been there since 1993. And it didn't change since, AFAIK.
> I am choosing smaller code.
Great, as long as it mixes compatible types, smaller to larger.
And than we have prototypes.
What's the point of having that and not respecting it?
> Do you really think strings longer than 2 gigabytes
> are typical enough to worry about?
I'm no longer that young and worry free like you are :)
CMIIW, but robustness is not a negative quality.
Cheers,
--
Cristian
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox