Update of /cvsroot/arcem/arcem/arch In directory vz-cvs-4.sog:/tmp/cvs-serv9731/arch
Modified Files: Tag: arcem-fast i2c.c Log Message: Check fscanf()'s success when reading hexcmos's file's contents; exit(1) if there's a problem. Index: i2c.c =================================================================== RCS file: /cvsroot/arcem/arcem/arch/i2c.c,v retrieving revision 1.12.2.4 retrieving revision 1.12.2.5 diff -u -d -r1.12.2.4 -r1.12.2.5 --- i2c.c 31 Oct 2011 00:52:14 -0000 1.12.2.4 +++ i2c.c 31 Oct 2011 00:59:14 -0000 1.12.2.5 @@ -430,28 +430,33 @@ static void SetUpCMOS(ARMul_State *state) { + const char *path; FILE *fp; int byte, dest; unsigned int val; #if defined(__riscos__) - fp = fopen("<ArcEm$Dir>.hexcmos", "r"); + path = "<ArcEm$Dir>.hexcmos"; #elif defined(MACOSX) chdir(arcemDir); - fp = fopen("hexcmos", "r"); + path = "hexcmos"; #elif defined(SYSTEM_gp2x) - fp = fopen("/mnt/sd/arcem/hexcmos", "r"); + path = "/mnt/sd/arcem/hexcmos"; #else - fp = fopen("hexcmos", "r"); + path = "hexcmos"; #endif - if (fp == NULL) + if ((fp = fopen(path, "r")) == NULL) fputs("SetUpCMOS: Could not open (hexcmos) CMOS settings file, " "resetting to internal defaults.\n", stderr); for (byte = 0; byte < 240; byte++) { if (fp) { - fscanf(fp, "%x\n", &val); + if (fscanf(fp, "%x\n", &val) != 1) { + fprintf(stderr, "arcem: failed to read value %d of %s\n", + byte, path); + exit(1); + } } else { val = CMOSDefaults[byte]; } ------------------------------------------------------------------------------ Get your Android app more play: Bring it to the BlackBerry PlayBook in minutes. BlackBerry App World™ now supports Android™ Apps for the BlackBerry® PlayBook™. Discover just how easy and simple it is! http://p.sf.net/sfu/android-dev2dev -- arcem-cvs mailing list arcem-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/arcem-cvs