1
0
Fork 0
forked from len0rd/rockbox

Correct checking return value of open in plugins.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23874 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-12-06 13:52:28 +00:00
parent e760a5abbf
commit 5cdd920d12
11 changed files with 20 additions and 14 deletions

View file

@ -1046,6 +1046,8 @@ static void brickmania_savegame(void)
/* write out the game state to the save file */
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT);
if(fd < 0) return;
rb->write(fd, &pad_pos_x, sizeof(pad_pos_x));
rb->write(fd, &life, sizeof(life));
rb->write(fd, &game_state, sizeof(game_state));

View file

@ -564,7 +564,7 @@ struct pgn_game_node* pgn_list_games(const char* filename){
int line_count = 0;
bool header_start = true, game_start = false;
if ( (fhandler = rb->open(filename, O_RDONLY)) == 0 ) return NULL;
if ( (fhandler = rb->open(filename, O_RDONLY)) < 0 ) return NULL;
if (bufptr == NULL){
pl_malloc_init();

View file

@ -1329,7 +1329,7 @@ static bool chip8_init(const char* file)
int i;
fd = rb->open(file, O_RDONLY);
if (fd==-1) {
if (fd < 0) {
rb->lcd_puts(0, 6, "File Error.");
return false;
}
@ -1351,7 +1351,7 @@ static bool chip8_init(const char* file)
c8kname[len-2] = '8';
c8kname[len-1] = 'k';
fd = rb->open(c8kname, O_RDONLY);
if (fd!=-1) {
if (fd >= 0) {
rb->lcd_puts(0, 6, "File&Keymap OK.");
numread = rb->read(fd, chip8_keymap, 16);
rb->close(fd);

View file

@ -480,6 +480,8 @@ static void jewels_savegame(struct game_context* bj)
int fd;
/* write out the game state to the save file */
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT);
if(fd < 0) return;
rb->write(fd, &bj->tmp_type, sizeof(bj->tmp_type));
rb->write(fd, &bj->type, sizeof(bj->type));
rb->write(fd, &bj->score, sizeof(bj->score));

View file

@ -160,7 +160,7 @@ struct GPatch * gusload(char * filename)
int file = rb->open(filename, O_RDONLY);
if(file == -1)
if(file < 0)
{
char message[50];
rb->snprintf(message, 50, "Error opening %s", filename);

View file

@ -31,7 +31,7 @@ struct MIDIfile * loadFile(const char * filename)
struct MIDIfile * mfload;
int file = rb->open (filename, O_RDONLY);
if(file==-1)
if(file < 0)
{
printf("Could not open file");
return NULL;

View file

@ -133,7 +133,7 @@ bool custom_dir(void)
int i, errors = 0;
/* populate removed dirs array */
if((fd2 = rb->open(RFADIR_FILE,O_RDONLY)) > 0)
if((fd2 = rb->open(RFADIR_FILE,O_RDONLY)) >= 0)
{
while ((rb->read_line(fd2, line, MAX_PATH - 1)) > 0)
{
@ -148,7 +148,7 @@ bool custom_dir(void)
rb->close(fd2);
}
if((fd2 = rb->open(RFADIR_FILE,O_RDONLY)) > 0)
if((fd2 = rb->open(RFADIR_FILE,O_RDONLY)) >= 0)
{
while ((rb->read_line(fd2, line, MAX_PATH - 1)) > 0)
{

View file

@ -178,7 +178,7 @@ static bool do_file(char *path, char *desc, bool is_load) {
file_mode = is_load ? O_RDONLY : (O_WRONLY | O_CREAT);
/* attempt to open file descriptor here */
if ((fd = open(path, file_mode)) <= 0)
if ((fd = open(path, file_mode)) < 0)
return false;
/* load/save state */

View file

@ -121,7 +121,7 @@ static bool search_init(const char* file){
clear_display();
rb->splash(0, "Searching...");
fd = rb->open(file, O_RDONLY);
if (fd==-1)
if (fd < 0)
return false;
fdw = rb->creat(resultfile);
@ -132,6 +132,7 @@ static bool search_init(const char* file){
#else
rb->splash(HZ, "File creation failed");
#endif
rb->close(fd);
return false;
}
@ -153,8 +154,9 @@ enum plugin_status plugin_start(const void* parameter)
DEBUGF("%s - %s\n", (char *)parameter, &filename[rb->strlen(filename)-4]);
/* Check the extension. We only allow .m3u files. */
if(rb->strcasecmp(&filename[rb->strlen(filename)-4], ".m3u") &&
rb->strcasecmp(&filename[rb->strlen(filename)-5], ".m3u8")) {
if (!(p = rb->strrchr(filename, '.')) ||
(rb->strcasecmp(p, ".m3u") && rb->strcasecmp(p, ".m3u8")))
{
rb->splash(HZ, "Not a .m3u or .m3u8 file");
return PLUGIN_ERROR;
}

View file

@ -1935,7 +1935,7 @@ static int load_game(const char* file) {
int fd;
fd = rb->open(file, O_RDONLY);
if(fd == 0) {
if(fd < 0) {
DEBUGF("Couldn't open savegame\n");
return -1;
}

View file

@ -1193,7 +1193,7 @@ static bool viewer_init(void)
#endif
fd = rb->open(file_name, O_RDONLY);
if (fd==-1)
if (fd < 0)
return false;
file_size = rb->filesize(fd);