# HG changeset patch # User Guido Berhoerster # Date 1486299279 -3600 # Node ID 0b1bce8db371da7bab3e7404a4b5312a5f0e61cb # Parent b5c4267a7182b7584707713c61c14a708b54b5e3 Prevent misleading double error message Display errors from the function where they occur. Only use warn(x) for system errors. diff -r b5c4267a7182 -r 0b1bce8db371 pwfile.c --- a/pwfile.c Sun Feb 05 13:30:31 2017 +0100 +++ b/pwfile.c Sun Feb 05 13:54:39 2017 +0100 @@ -172,7 +172,7 @@ struct record_id_entry *entry; if (pws3_file_read_stream(ctx->file, ctx->password, fp) != 0) { - warnx("failed to read password database: %s", + fprintf(stderr, "failed to read password database: %s\n", pws3_file_get_error_message(ctx->file)); return (-1); } diff -r b5c4267a7182 -r 0b1bce8db371 pwm.c --- a/pwm.c Sun Feb 05 13:30:31 2017 +0100 +++ b/pwm.c Sun Feb 05 13:54:39 2017 +0100 @@ -197,10 +197,12 @@ password_len--; if (password_len == 0) { /* first line is empty */ + fprintf(stderr, "malformed password file\n"); goto out; } } else if (!feof(fp)) { /* the first line was truncated, password is too long */ + fprintf(stderr, "malformed password file\n"); goto out; } memcpy(password, buf, password_size); @@ -318,7 +320,6 @@ if (master_password_filename != NULL) { if (read_password_from_file(master_password_filename, ctx.password, sizeof (ctx.password)) != 0) { - fprintf(stderr, "malformed password database\n"); goto out; } } else {