Hi,
today i tried to compile ephoto on openSUSE 10.2 (gcc version 4.1.2 20061115)
but the build failed because ephoto is built with
"-Wall -Werror ... -D_FORTIFY_SOURCE=2":
if gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/include/ewl
-I/usr/include/libexif -Wall -Werror -O2 -g -m32 -march=i586 -mtune=i686
-fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT ephoto-ephoto.o -MD -MP -MF
".deps/ephoto-ephoto.Tpo" -c -o ephoto-ephoto.o `test -f 'ephoto.c' || echo
'./'`ephoto.c; \
then mv -f ".deps/ephoto-ephoto.Tpo" ".deps/ephoto-ephoto.Po"; else rm
-f ".deps/ephoto-ephoto.Tpo"; exit 1; fi
cc1: warnings being treated as errors
ephoto.c: In function 'main':
ephoto.c:74: warning: ignoring return value of 'scanf', declared with
attribute warn_unused_result
ephoto.c:115: warning: ignoring return value of 'scanf', declared with
attribute warn_unused_result
ephoto.c:148: warning: ignoring return value of 'scanf', declared with
attribute warn_unused_result
ephoto.c:214: warning: ignoring return value of 'scanf', declared with
attribute warn_unused_result
ephoto.c:248: warning: ignoring return value of 'scanf', declared with
attribute warn_unused_result
make[3]: *** [ephoto-ephoto.o] Error 1
If you check the return value of each scanf() call everything is ok.
A patch is attached.
Marcus
--- src/bin/ephoto.c.old 2007-04-19 05:17:11.000000000 +0200
+++ src/bin/ephoto.c 2007-05-19 23:57:22.000000000 +0200
@@ -71,7 +71,12 @@ int main(int argc, char **argv)
printf("Are you sure you want to create an album with "
"the name %s and the description %s? ",
name, description);
- scanf("%c", &input);
+ int ret = scanf("%c", &input);
+ if(!ret || ret == EOF)
+ {
+ printf("read error\n");
+ return 1;
+ }
if(input == 'y' || input == 'Y')
{
db = ephoto_db_init();
@@ -112,7 +117,12 @@ int main(int argc, char **argv)
printf("Are you sure you want to add an image "
"to album %s with a name %s and path %s? ",
album, name, path);
- scanf("%c", &input);
+ int ret = scanf("%c", &input);
+ if(!ret || ret == EOF)
+ {
+ printf("read error\n");
+ return 1;
+ }
if(input == 'y' || input == 'Y')
{
db = ephoto_db_init();
@@ -145,7 +155,12 @@ int main(int argc, char **argv)
printf("Are you sure you want to add images "
"from the directory %s to the album %s? ",
path, album);
- scanf("%c", &input);
+ int ret = scanf("%c", &input);
+ if(!ret || ret == EOF)
+ {
+ printf("read error\n");
+ return 1;
+ }
if(input == 'y' || input == 'Y')
{
db = ephoto_db_init();
@@ -211,7 +226,12 @@ int main(int argc, char **argv)
printf("Are you sure you want to remove the album %s? ",
name);
- scanf("%c", &input);
+ int ret = scanf("%c", &input);
+ if(!ret || ret == EOF)
+ {
+ printf("read error\n");
+ return 1;
+ }
if(input == 'y' || input == 'Y')
{
db = ephoto_db_init();
@@ -245,7 +265,12 @@ int main(int argc, char **argv)
printf("Are you sure you want to remove the image %s "
"from the album %s? ",
path, album);
- scanf("%c", &input);
+ int ret = scanf("%c", &input);
+ if(!ret || ret == EOF)
+ {
+ printf("read error\n");
+ return 1;
+ }
if(input == 'y' || input == 'Y')
{
db = ephoto_db_init();
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel