View Issue Details

IDProjectCategoryView StatusLast Update
0000490LDMud 3.2Portabilitypublic2018-01-29 21:57
Reporterzippo Assigned Tolars 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.2.13 
Fixed in Version3.2.16 
Summary0000490: x86_64 sprintf.c problem
DescriptionThis is actually for 3.2.14, but it's not listed in Mantis.

sprintf.c: In function `string_print_formatted':
sprintf.c:1681: warning: comparison is always false due to limited range of data type
sprintf.c:1682: warning: large integer implicitly truncated to unsigned type
Additional InformationEither the "fs" variable should be unsigned long (instead of unsigned int), or we should be using INT_MAX and INT_MIN instead of PINT_MAX and PINT_MIN here.

On my system, SIZEOF_LONG and SIZEOF_CHAR_P are both == 8, and PINT_MAX then = LONG_MAX (and PINT_MIN = LONG_MIN). But the "fs" variable is unsigned int.
TagsNo tags attached.

Activities

zippo

2006-11-12 21:28

reporter   ~0000519

Actually, looking a bit further, it doesn't seem to make sense that fs is unsigned:

if (fs == WHATEVER_MINIMUM) { fs = WHATEVER_MAXIMUM } else { fs = -fs }

I was going to say that since it's unsigned int, we should have if (fs == 0) { fs = UINT_MAX } ... but then I read the 'else' clause, and it doesn't make much sense to me.

I guess I'm just confused, and you'll probably know the answer before I finish typing this. Either way, something is amiss.

lars

2007-10-06 19:19

reporter   ~0000551

I believe to resolve this problem it is sufficient to define fs as type p_uint (which is the unsigned variant of p_int). I don't have a x86-64 at my hands, so you'll have to check the correction.

fs is unsigned as it is supposed to handle the always-positive field size. The code in question however reads the fieldsize from the given NUMBER svalue, where a negative value indicates a left-aligned field (default is right-aligned): in that case, the negative value needs to be converted safely into its corresponding positive one.

Issue History

Date Modified Username Field Change
2006-11-12 21:15 zippo New Issue
2006-11-12 21:28 zippo Note Added: 0000519
2007-10-06 19:19 lars Status new => resolved
2007-10-06 19:19 lars Fixed in Version => 3.2.16
2007-10-06 19:19 lars Resolution open => fixed
2007-10-06 19:19 lars Assigned To => lars
2007-10-06 19:19 lars Note Added: 0000551
2010-11-16 09:42 lars Source_changeset_attached => ldmud.git master 9e29f382
2010-11-16 09:42 lars Source_changeset_attached => ldmud.git master-3.2 6d38e39b
2018-01-29 18:59 lars Source_changeset_attached => ldmud.git master 9e29f382
2018-01-29 18:59 lars Source_changeset_attached => ldmud.git master-3.2 6d38e39b
2018-01-29 21:57 lars Source_changeset_attached => ldmud.git master 9e29f382
2018-01-29 21:57 lars Source_changeset_attached => ldmud.git master-3.2 6d38e39b