Small fixes

This commit is contained in:
Qball Cow 2014-05-13 22:11:42 +02:00
parent 87b51f5430
commit a925e59653
2 changed files with 18 additions and 12 deletions

View File

@ -153,12 +153,13 @@ void history_set ( const char *filename, const char *entry )
// Rewind.
fseek(fd, 0L, SEEK_SET);
// Clear file.
ftruncate(fileno(fd), 0);
// Write list.
__history_write_element_list(fd, list, length);
if ( ftruncate(fileno(fd), 0) == 0)
{
// Write list.
__history_write_element_list(fd, list, length);
}else {
fprintf(stderr, "Failed to truncate file: %s\n", strerror(errno));
}
// Free the list.
for(unsigned int iter = 0; iter < length; iter++)
{
@ -207,10 +208,12 @@ void history_remove ( const char *filename, const char *entry )
// Rewind.
fseek(fd, 0L, SEEK_SET);
// Clear list.
ftruncate(fileno(fd), 0);
// Write list.
__history_write_element_list(fd, list, length);
if(ftruncate(fileno(fd), 0) == 0) {
// Write list.
__history_write_element_list(fd, list, length);
} else {
fprintf(stderr, "Failed to open file: %s\n", strerror(errno));
}
}
// Free the list.

View File

@ -151,9 +151,12 @@ static char ** get_ssh ( )
num_favorites = index;
}
FILE *fd = NULL;
const char *hd = getenv ( "HOME" );
asprintf ( &path, "%s/%s", hd, ".ssh/config" );
FILE *fd = fopen ( path, "r" );
if(asprintf ( &path, "%s/%s", hd, ".ssh/config" )>= 0){
fd = fopen ( path, "r" );
}
if ( fd != NULL )
{