Bug 22710

Summary: snake_saver and star_saver fail to compile with -Wall -Werror
Product: Base System Reporter: gordont <gordont>
Component: kernAssignee: yokota <yokota>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description gordont 2000-11-09 02:10:01 UTC
	
Compiling snake_saver.ko and star_saver.ko with -Wall -Werror produces an
error about array indices being of type 'char'

Fix: similar to PR 22709. Was bored at work and thought I would do something very
minorly constructive.

-gordon
How-To-Repeat: 
	
(Again, assuming Bourne Shell)
cd /usr/src/sys/modules/syscons/{snake,star}
CC='cc -Wall -Werror' make
Comment 1 peter 2000-11-09 08:23:59 UTC
gordont@bluemtn.net wrote:
[..]
> similar to PR 22709. Was bored at work and thought I would do something very
> minorly constructive.
> 
> -gordon
> -			sc_vtb_putc(&scp->scr, savs[0], sc->scr_map[*save],
> +			sc_vtb_putc(&scp->scr, savs[0], sc->scr_map[(int) *save

Actually, this is quite incorrect..  All you are doing is hiding the problem
instead of fixing it.  If you have 0x80 (-128 decimal), then casting it to
an int ends up with (int) -128, which is still a negative array offset.

sc->scr_map[(unsigned char)*save]; 

would work, because you end up with a positive index value in all cases.

I'm one of these crazy people that likes to compile things with
switches like -funsigned-char. :-)

Cheers,
-Peter
--
Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au
"All of this is for nothing if we don't go to the stars" - JMS/B5
Comment 2 dirk freebsd_committer freebsd_triage 2000-11-09 11:45:56 UTC
Responsible Changed
From-To: gnats-admin->yokota

Over to Mr. syscons... 

Kazutaka, can you please look at the patches and commit them  
if appropriate?
Comment 3 gordont 2000-11-09 20:27:11 UTC
On Thu, 9 Nov 2000, Peter Wemm wrote:

> sc->scr_map[(unsigned char)*save]; 
> 
> would work, because you end up with a positive index value in all cases.
> 
> I'm one of these crazy people that likes to compile things with
> switches like -funsigned-char. :-)

Well, it would probably be better to use the cast since that makes it
explicit. It's been a while since I've done C, which is why I wanted to
work on something small to begin with.

Also, compiling with switches -Wall -Werror -funsigned-char still causes
the make to error-out.

-gordon
Comment 4 yokota freebsd_committer freebsd_triage 2001-07-20 16:04:12 UTC
State Changed
From-To: open->closed

Fixed by nyan in both 5.0-CURRENT and RELENG_4.