From ac7c3f475ccc1689b7d32436e5d001f604acb6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Sun, 13 Aug 2023 15:52:27 +0000 Subject: [PATCH] cyrusdb.c:cyrusdb_fromname() simplify --- lib/cyrusdb.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/cyrusdb.c b/lib/cyrusdb.c index 63f79550a2..2b7ed4ab8c 100644 --- a/lib/cyrusdb.c +++ b/lib/cyrusdb.c @@ -96,22 +96,16 @@ struct db { static struct cyrusdb_backend *cyrusdb_fromname(const char *name) { - int i; - struct cyrusdb_backend *db = NULL; - - for (i = 0; _backends[i]; i++) { + for (int i = 0; _backends[i]; i++) { if (!strcmp(_backends[i]->name, name)) { - db = _backends[i]; break; + return _backends[i]; } } - if (!db) { - char errbuf[1024]; - snprintf(errbuf, sizeof(errbuf), - "cyrusdb backend %s not supported", name); - fatal(errbuf, EX_CONFIG); - } - return db; + char errbuf[1024]; + snprintf(errbuf, sizeof(errbuf), + "cyrusdb backend %s not supported", name); + fatal(errbuf, EX_CONFIG); } static int _myopen(const char *backend, const char *fname,