Browse Source

Simplify error handling in gfsec-split

We no longer care about memory allocation failures.
master
Damien Goutte-Gattat 5 years ago
parent
commit
e23eb6dcb7
  1. 21
      src/gfsec-split.c

21
src/gfsec-split.c

@ -32,6 +32,8 @@
#include <gcrypt.h>
#include <xmem.h>
#include "util.h"
#include "secretcfg.h"
#include "scheme-module.h"
@ -102,7 +104,7 @@ main(int argc, char **argv)
{
int c, list_mode;
unsigned threshold, keep_original;
char *output_base, *config_path;
char *config_path;
gfsec_secret_t *cfg;
struct option options[] = {
@ -119,12 +121,11 @@ main(int argc, char **argv)
setprogname(argv[0]);
threshold = 2;
keep_original = list_mode = 0;
output_base = config_path = NULL;
config_path = NULL;
srandom(time(NULL));
if ( ! (cfg = gfsec_secret_new()) )
err(EXIT_FAILURE, "Cannot create secret");
cfg = gfsec_secret_new();
while ( (c = getopt_long(argc, argv, "hvn:s:c:kl",
options, NULL)) != -1 ) {
@ -180,18 +181,12 @@ main(int argc, char **argv)
if ( optind >= argc )
errx(EXIT_FAILURE, "Missing secret file");
if ( ! output_base && ! (output_base = get_file_basename(argv[optind])) )
err(EXIT_FAILURE, "No output basename");
if ( ! config_path ) {
char *base;
if ( ! (base = get_file_basename(argv[optind])) )
err(EXIT_FAILURE, "Cannot get basename");
if ( asprintf(&config_path, "%s/gfsecret/%s.conf",
getenv("XDG_CONFIG_HOME"), base) == -1 )
err(EXIT_FAILURE, "Cannot construct a pathname for the configuration file");
base = get_file_basename(argv[optind]);
xasprintf(&config_path, "%s/gfsecret/%s.conf",
getenv("XDG_CONFIG_HOME"), base);
free(base);
}

Loading…
Cancel
Save