zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@zdharma.org>
To: zsh-workers@zsh.org
Subject: [PATCH] Use gdbm_errno with gdbm_open
Date: Sat, 25 Mar 2017 07:55:54 +0100	[thread overview]
Message-ID: <etPan.58d6147a.643c9869.17199@MacMini.local> (raw)

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

Hello,
there was one report about gdbm_open() failing. The patch uses gdbm_errno / gdbm_strerror() to know what exactly happened. I've checked that it works:

ztie: error opening database file /Users/sgniazdowski/db3 (Can't be writer)

– after ztie to already opened database. I hope Airmail will not mess up the patch. It is also attached.

Sebastian Gniazdowski
psprint [at] zdharma.org

diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 596a8ae..0a28a07 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -154,12 +154,13 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
 	    return 1;
     }
 
+    gdbm_errno=0;
     dbf = gdbm_open(resource_name, 0, read_write, 0666, 0);
     if(dbf) {
 	addmodulefd(gdbm_fdesc(dbf), FDT_MODULE);
         append_tied_name(pmname);
     } else {
-	zwarnnam(nam, "error opening database file %s", resource_name);
+	zwarnnam(nam, "error opening database file %s (%s)", resource_name, gdbm_strerror(gdbm_errno));
 	return 1;
     }
 

[-- Attachment #2: gdbm_errno.diff --]
[-- Type: application/octet-stream, Size: 629 bytes --]

diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 596a8ae..0a28a07 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -154,12 +154,13 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
 	    return 1;
     }
 
+    gdbm_errno=0;
     dbf = gdbm_open(resource_name, 0, read_write, 0666, 0);
     if(dbf) {
 	addmodulefd(gdbm_fdesc(dbf), FDT_MODULE);
         append_tied_name(pmname);
     } else {
-	zwarnnam(nam, "error opening database file %s", resource_name);
+	zwarnnam(nam, "error opening database file %s (%s)", resource_name, gdbm_strerror(gdbm_errno));
 	return 1;
     }
 

             reply	other threads:[~2017-03-25  6:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-25  6:55 Sebastian Gniazdowski [this message]
2017-03-25 10:12 ` Daniel Shahaf
2017-03-25 13:52   ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=etPan.58d6147a.643c9869.17199@MacMini.local \
    --to=psprint@zdharma.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).