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:
parent
e760a5abbf
commit
5cdd920d12
11 changed files with 20 additions and 14 deletions
|
|
@ -1046,6 +1046,8 @@ static void brickmania_savegame(void)
|
||||||
|
|
||||||
/* write out the game state to the save file */
|
/* write out the game state to the save file */
|
||||||
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT);
|
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, &pad_pos_x, sizeof(pad_pos_x));
|
||||||
rb->write(fd, &life, sizeof(life));
|
rb->write(fd, &life, sizeof(life));
|
||||||
rb->write(fd, &game_state, sizeof(game_state));
|
rb->write(fd, &game_state, sizeof(game_state));
|
||||||
|
|
|
||||||
|
|
@ -564,7 +564,7 @@ struct pgn_game_node* pgn_list_games(const char* filename){
|
||||||
int line_count = 0;
|
int line_count = 0;
|
||||||
bool header_start = true, game_start = false;
|
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){
|
if (bufptr == NULL){
|
||||||
pl_malloc_init();
|
pl_malloc_init();
|
||||||
|
|
@ -572,7 +572,7 @@ struct pgn_game_node* pgn_list_games(const char* filename){
|
||||||
while (rb->read_line(fhandler, line_buffer, sizeof line_buffer) > 0){
|
while (rb->read_line(fhandler, line_buffer, sizeof line_buffer) > 0){
|
||||||
line_count++;
|
line_count++;
|
||||||
/* looking for a game header */
|
/* looking for a game header */
|
||||||
if (header_start) {
|
if (header_start) {
|
||||||
/* a new game header is found */
|
/* a new game header is found */
|
||||||
if (line_buffer[0] == '['){
|
if (line_buffer[0] == '['){
|
||||||
temp_node = (struct pgn_game_node *)pl_malloc(sizeof size_node);
|
temp_node = (struct pgn_game_node *)pl_malloc(sizeof size_node);
|
||||||
|
|
|
||||||
|
|
@ -1329,7 +1329,7 @@ static bool chip8_init(const char* file)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fd = rb->open(file, O_RDONLY);
|
fd = rb->open(file, O_RDONLY);
|
||||||
if (fd==-1) {
|
if (fd < 0) {
|
||||||
rb->lcd_puts(0, 6, "File Error.");
|
rb->lcd_puts(0, 6, "File Error.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1351,7 +1351,7 @@ static bool chip8_init(const char* file)
|
||||||
c8kname[len-2] = '8';
|
c8kname[len-2] = '8';
|
||||||
c8kname[len-1] = 'k';
|
c8kname[len-1] = 'k';
|
||||||
fd = rb->open(c8kname, O_RDONLY);
|
fd = rb->open(c8kname, O_RDONLY);
|
||||||
if (fd!=-1) {
|
if (fd >= 0) {
|
||||||
rb->lcd_puts(0, 6, "File&Keymap OK.");
|
rb->lcd_puts(0, 6, "File&Keymap OK.");
|
||||||
numread = rb->read(fd, chip8_keymap, 16);
|
numread = rb->read(fd, chip8_keymap, 16);
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,8 @@ static void jewels_savegame(struct game_context* bj)
|
||||||
int fd;
|
int fd;
|
||||||
/* write out the game state to the save file */
|
/* write out the game state to the save file */
|
||||||
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT);
|
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->tmp_type, sizeof(bj->tmp_type));
|
||||||
rb->write(fd, &bj->type, sizeof(bj->type));
|
rb->write(fd, &bj->type, sizeof(bj->type));
|
||||||
rb->write(fd, &bj->score, sizeof(bj->score));
|
rb->write(fd, &bj->score, sizeof(bj->score));
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ struct GPatch * gusload(char * filename)
|
||||||
|
|
||||||
int file = rb->open(filename, O_RDONLY);
|
int file = rb->open(filename, O_RDONLY);
|
||||||
|
|
||||||
if(file == -1)
|
if(file < 0)
|
||||||
{
|
{
|
||||||
char message[50];
|
char message[50];
|
||||||
rb->snprintf(message, 50, "Error opening %s", filename);
|
rb->snprintf(message, 50, "Error opening %s", filename);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ struct MIDIfile * loadFile(const char * filename)
|
||||||
struct MIDIfile * mfload;
|
struct MIDIfile * mfload;
|
||||||
int file = rb->open (filename, O_RDONLY);
|
int file = rb->open (filename, O_RDONLY);
|
||||||
|
|
||||||
if(file==-1)
|
if(file < 0)
|
||||||
{
|
{
|
||||||
printf("Could not open file");
|
printf("Could not open file");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ bool custom_dir(void)
|
||||||
int i, errors = 0;
|
int i, errors = 0;
|
||||||
|
|
||||||
/* populate removed dirs array */
|
/* 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)
|
while ((rb->read_line(fd2, line, MAX_PATH - 1)) > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -148,7 +148,7 @@ bool custom_dir(void)
|
||||||
rb->close(fd2);
|
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)
|
while ((rb->read_line(fd2, line, MAX_PATH - 1)) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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);
|
file_mode = is_load ? O_RDONLY : (O_WRONLY | O_CREAT);
|
||||||
|
|
||||||
/* attempt to open file descriptor here */
|
/* attempt to open file descriptor here */
|
||||||
if ((fd = open(path, file_mode)) <= 0)
|
if ((fd = open(path, file_mode)) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* load/save state */
|
/* load/save state */
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ static bool search_init(const char* file){
|
||||||
clear_display();
|
clear_display();
|
||||||
rb->splash(0, "Searching...");
|
rb->splash(0, "Searching...");
|
||||||
fd = rb->open(file, O_RDONLY);
|
fd = rb->open(file, O_RDONLY);
|
||||||
if (fd==-1)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fdw = rb->creat(resultfile);
|
fdw = rb->creat(resultfile);
|
||||||
|
|
@ -132,6 +132,7 @@ static bool search_init(const char* file){
|
||||||
#else
|
#else
|
||||||
rb->splash(HZ, "File creation failed");
|
rb->splash(HZ, "File creation failed");
|
||||||
#endif
|
#endif
|
||||||
|
rb->close(fd);
|
||||||
return false;
|
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]);
|
DEBUGF("%s - %s\n", (char *)parameter, &filename[rb->strlen(filename)-4]);
|
||||||
/* Check the extension. We only allow .m3u files. */
|
/* Check the extension. We only allow .m3u files. */
|
||||||
if(rb->strcasecmp(&filename[rb->strlen(filename)-4], ".m3u") &&
|
if (!(p = rb->strrchr(filename, '.')) ||
|
||||||
rb->strcasecmp(&filename[rb->strlen(filename)-5], ".m3u8")) {
|
(rb->strcasecmp(p, ".m3u") && rb->strcasecmp(p, ".m3u8")))
|
||||||
|
{
|
||||||
rb->splash(HZ, "Not a .m3u or .m3u8 file");
|
rb->splash(HZ, "Not a .m3u or .m3u8 file");
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1935,7 +1935,7 @@ static int load_game(const char* file) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = rb->open(file, O_RDONLY);
|
fd = rb->open(file, O_RDONLY);
|
||||||
if(fd == 0) {
|
if(fd < 0) {
|
||||||
DEBUGF("Couldn't open savegame\n");
|
DEBUGF("Couldn't open savegame\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1193,7 +1193,7 @@ static bool viewer_init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fd = rb->open(file_name, O_RDONLY);
|
fd = rb->open(file_name, O_RDONLY);
|
||||||
if (fd==-1)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
file_size = rb->filesize(fd);
|
file_size = rb->filesize(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue