Bug 136907

Summary: pine-4.63-9: undefined C code
Product: [openSUSE] SUSE LINUX 10.0 Reporter: David Binderman <dcb314>
Component: BasesystemAssignee: Bernhard Kaindl <bk>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: SuSE Linux 10.0   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description David Binderman 2005-12-05 14:26:45 UTC
I just tried to compile package pine-4.63-9 with a prerelease of the
GNU C compiler version 4.1. It said

help.c:1882: warning: operation on `i' may be undefined

The source code is

    sprintf(tmp_20k_buf, "%s (ID %c%c%d%c%c)", key,
            ((i = (int)(random() % 36L)) < 10) ? '0' + i : 'A' + (i - 10),
            ((i = (int)(random() % 36L)) < 10) ? '0' + i : 'A' + (i - 10),
            (int)(random() % 10L),
            ((i = (int)(random() % 36L)) < 10) ? '0' + i : 'A' + (i - 10),
            ((i = (int)(random() % 36L)) < 10) ? '0' + i : 'A' + (i - 10));

I agree with the compiler - this code seems to be undefined.

Suggest code rework.
Comment 1 Gary Ekker 2005-12-07 20:06:54 UTC
We are using 4.1 in our build system, as well as a newer version of pine-4.64. This warning still exists. 

We don't rework code just for the fun of it, this type of bug should really be reported upstream. If you do have a reasonable patch, I'd be happy to take it.
Comment 2 David Binderman 2005-12-07 22:27:53 UTC
>This warning still exists. 

Oh dear.

>this type of bug should really be reported upstream.

The fact that Novell got it does mean that I couldn't figure out
who to send it to upstream.

>If you do have a reasonable patch, I'd be happy to take it.

I would have thought that a reasonable patch would have been
trivial: Merely declare four new local variables, compute the
four intermediate sums into the new four local variables,
and then use the four new local variables in the call to
sprintf.
 
Comment 3 Gary Ekker 2006-02-27 20:36:40 UTC
Bernard, do you want to ad this fix the next time you touch pine?
Comment 4 Bernhard Kaindl 2007-01-31 18:01:53 UTC
It's fixed in our pine for 10.3.

I guess that at some point (bug 228344 is finally fixed),
I'll be doing a package for alpine (the next version of pine)
and check if it's still there and report upstream as it's
one of the patches which is on the pocket there.