Subject: A C question

From: Steve Robbins <[email-masked]>
Date: Sat, 10 Apr 1999 17:30:25 -0400 (EDT)

Hi gang,

Am I wrong in thinking that 

	char c;
	scanf( "%d", &c );

is illegal?  

I thought that "char c" promised only a single writable byte of storage,
whereas the scanf is going to assume a pointer to an integer.  Hence we
run the risk of SEGV, no?

--
Steve Robbins                              <[email-masked]>

I was looking back to see
if you were looking back at me
to see me looking back at you.

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Matthias Clasen <[email-masked]>
Date: Sat, 10 Apr 1999 23:45:50 +0200

> Date: Sat, 10 Apr 1999 17:30:25 -0400 (EDT)
> From: Steve Robbins <[email-masked]>
> Content-Type: TEXT/PLAIN; charset=US-ASCII
> Sender: [email-masked]
> Precedence: list
> X-Majordomo: 1.94.jlt7
> 
> Hi gang,
> 

If you are referring to session.c then I'm sorry, its my fault.
Dominik had an int there.

Matthias

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Steve Robbins <[email-masked]>
Date: Sat, 10 Apr 1999 18:17:38 -0400 (EDT)

> Dominik had an int there.

Yes, that's what I'm referring to.  The original code was reading into a
"char".  I changed it to an int.  Then it got changed back to reading into
a char. 

Since I was outvoted by two changes to one, I thought maybe my
understanding of this was flawed.  ;-)

A man came up to me and said, "I'd like to change your mind,
by hitting it with a rock," he said, "though I am not unkind."

---

From: Matthias Clasen <[email-masked]>
Date: Sun, 11 Apr 1999 00:56:37 +0200

> understanding of this was flawed.  ;-)

I guess you are right, since compiling the current session.c with
-Wformat (causes gcc to check sscanf arguments) gives:

gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../libs  -I/usr/X11R6/include
-DFVWM_MODULEDIR=\"/usr/local/libexec/fvwm/2.3.1\"
-DFVWM_CONFIGDIR=\"/usr/local/etc\" -Wformat -c session.c
session.c: In function `LoadWindowStates':
session.c:391: warning: unsigned int format, different type arg (arg 3)

Matthias

---

From: Steve Robbins <[email-masked]>
Date: Sun, 11 Apr 1999 01:02:20 -0400 (EDT)

On Sun, 11 Apr 1999, Matthias Clasen wrote:

> -Wformat (causes gcc to check sscanf arguments)
  ^^^^^^^^
Yes, that's pretty handy, I find.  I am now compiling fvwm exclusively
with -Wall (which turns on -Wformat, among others).  I highly recommend
doing this.  Of course, it only works well if you have fully-prototyped
system- and X-headers.  Otherwise you might investigate shutting off
prototype warnings, or grep out stuff in /usr/include and /usr/...X11.

---

From: [email-masked] (Paul D. Smith)
Date: 14 Apr 1999 15:52:56 -0400

%% Steve Robbins <[email-masked]> writes:

  sr> Yes, that's pretty handy, I find.  I am now compiling fvwm
  sr> exclusively with -Wall (which turns on -Wformat, among others).  I
  sr> highly recommend doing this.  Of course, it only works well if you
  sr> have fully-prototyped system- and X-headers.  Otherwise you might
  sr> investigate shutting off prototype warnings, or grep out stuff in
  sr> /usr/include and /usr/...X11.

If we want to keep this up, you might consider also using -Werror to be
sure you don't allow any warnings through :).

Also, if you have grungy headers (like SunOS 4.x, for example) and
you're using GCC, you can win a little bit more by adding the
-D__USE_FIXED_PROTOTYPES__ option to the compile line; GCC will muck
through your headers and rewrite them to be more conformant, and this
flag will enable prototyping for various functions.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]