mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Print error to stderr when fclose fails.
This commit is contained in:
parent
fd8fbbf6c5
commit
69c75971f3
6 changed files with 33 additions and 16 deletions
|
@ -158,7 +158,9 @@ static char ** get_apps_external ( char **retv, unsigned int *length, unsigned i
|
|||
|
||||
( *length )++;
|
||||
}
|
||||
fclose ( inp );
|
||||
if ( fclose ( inp ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
retv[( *length ) ] = NULL;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "rofi.h"
|
||||
#include "dialogs/script.h"
|
||||
#include "helper.h"
|
||||
|
@ -64,7 +65,9 @@ static char **get_script_output ( const char *command, unsigned int *length )
|
|||
|
||||
( *length )++;
|
||||
}
|
||||
fclose ( inp );
|
||||
if ( fclose ( inp ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
|
|
|
@ -167,7 +167,9 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
index++;
|
||||
} while ( buffer[index] != '\0' && buffer[index] != '#' );
|
||||
}
|
||||
fclose ( fd );
|
||||
if ( fclose ( fd ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close hosts file: '%s'\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
|
||||
return retv;
|
||||
|
@ -252,7 +254,9 @@ static char ** get_ssh ( unsigned int *length )
|
|||
}
|
||||
}
|
||||
|
||||
fclose ( fd );
|
||||
if ( fclose ( fd ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close ssh configuration file: '%s'\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: check this is still fast enough. (takes 1ms on laptop.)
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include "rofi.h"
|
||||
#include "history.h"
|
||||
|
||||
|
@ -118,7 +120,7 @@ void history_set ( const char *filename, const char *entry )
|
|||
unsigned int length = 0;
|
||||
_element **list = NULL;
|
||||
// Open file for reading and writing.
|
||||
FILE *fd = fopen ( filename, "a+" );
|
||||
FILE *fd = g_fopen ( filename, "a+" );
|
||||
if ( fd == NULL ) {
|
||||
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
|
||||
return;
|
||||
|
@ -170,8 +172,10 @@ void history_set ( const char *filename, const char *entry )
|
|||
g_free ( list[iter] );
|
||||
}
|
||||
g_free ( list );
|
||||
// Close file.
|
||||
fclose ( fd );
|
||||
// Close file, if fails let user know on stderr.
|
||||
if ( fclose ( fd ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
|
||||
void history_remove ( const char *filename, const char *entry )
|
||||
|
@ -184,7 +188,7 @@ void history_remove ( const char *filename, const char *entry )
|
|||
unsigned int curr = 0;
|
||||
unsigned int length = 0;
|
||||
// Open file for reading and writing.
|
||||
FILE *fd = fopen ( filename, "a+" );
|
||||
FILE *fd = g_fopen ( filename, "a+" );
|
||||
if ( fd == NULL ) {
|
||||
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
|
||||
return;
|
||||
|
@ -229,8 +233,11 @@ void history_remove ( const char *filename, const char *entry )
|
|||
if ( list != NULL ) {
|
||||
g_free ( list );
|
||||
}
|
||||
// Close file.
|
||||
fclose ( fd );
|
||||
|
||||
// Close file, if fails let user know on stderr.
|
||||
if ( fclose ( fd ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
|
||||
}
|
||||
}
|
||||
|
||||
char ** history_get_list ( const char *filename, unsigned int *length )
|
||||
|
@ -243,7 +250,7 @@ char ** history_get_list ( const char *filename, unsigned int *length )
|
|||
_element **list = NULL;
|
||||
char **retv = NULL;
|
||||
// Open file.
|
||||
FILE *fd = fopen ( filename, "r" );
|
||||
FILE *fd = g_fopen ( filename, "r" );
|
||||
if ( fd == NULL ) {
|
||||
// File that does not exists is not an error, so ignore it.
|
||||
// Everything else? panic.
|
||||
|
@ -267,6 +274,9 @@ char ** history_get_list ( const char *filename, unsigned int *length )
|
|||
g_free ( list );
|
||||
}
|
||||
|
||||
fclose ( fd );
|
||||
// Close file, if fails let user know on stderr.
|
||||
if ( fclose ( fd ) != 0 ) {
|
||||
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
|
|
|
@ -116,9 +116,8 @@ void i3_support_focus_window ( Window id )
|
|||
|
||||
int i3_support_initialize ( Display *display )
|
||||
{
|
||||
// Free it,
|
||||
g_free ( i3_socket_path );
|
||||
i3_socket_path = NULL;
|
||||
// If we where initialized, clean this first.
|
||||
i3_support_free_internals ();
|
||||
// Get atom for I3_SOCKET_PATH
|
||||
Atom i3_sp_atom = XInternAtom ( display, "I3_SOCKET_PATH", False );
|
||||
|
||||
|
|
Loading…
Reference in a new issue