Assignment in test: OK?

Rich Salz rsalz at bbn.com
Fri Sep 28 23:34:49 AEST 1990


In <1990Sep26.124155.9856 at DRD.Com> mark at DRD.Com (Mark Lawrence) writes:
[Saber "complains" about the following]
>} if ( ( file_ptr = fopen (filename, mode) ) == NULL )
>} 	{
>} 	/* print a message and exit */
>} 	}

>  My concern was that Saber C would give a warning
>on code just like the above and I've learned to take Saber's warnings
>seriously.

Gee, I'm confused.  The following fragment generated no warnings
whatsoever:
    #include <stdio.h>
    main()
    {
	FILE *F;

	if ((F = fopen("t.out", "w")) == NULL)
	    printf("Open failure");
	else {
	    printf("Open fine\n");
	    (void)fclose(F);
	}
    }

Perhaps something else is going on in your code?  This is with version 2.1,
and with suppressesion 357,358 (using result of ?: or cast as an lvalue)
turned OFF.
	/r$
-- 
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.



More information about the Comp.lang.c mailing list