Jacek Masiulaniec wrote:
You have a point there, although aliases_get is not the only place
that could benefit from this.
That looked even cleaner. (;>
I would also have suggested this below too, but not sure you would agree.
The ret integer is define and assign a value a few times, however, never
used, so could also be removed as well.
Just a thought as you are looking into it.
Best,
Daniel
Index: aliases.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/aliases.c,v
retrieving revision 1.17
diff -N -u -p aliases.c
--- aliases.c 24 Apr 2009 10:02:35 -0000 1.17
+++ aliases.c 12 May 2009 15:42:00 -0000
@@ -64,20 +64,16 @@ aliases_exist(struct smtpd *env, char *username)
key.data = buf;
key.size = strlen(key.data) + 1;
- if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) == -1) {
- aliasesdb->close(aliasesdb);
- return 0;
- }
+ ret = aliasesdb->get(aliasesdb, &key, &val, 0);
aliasesdb->close(aliasesdb);
- return ret == 0 ? 1 : 0;
+ return (ret == 0);
}
int
aliases_get(struct smtpd *env, struct aliaseslist *aliases, char
*username)
{
char buf[MAXLOGNAME];
- int ret;
DBT key;
DBT val;
DB *aliasesdb;
@@ -100,7 +96,7 @@ aliases_get(struct smtpd *env, struct aliaseslist *ali
key.data = buf;
key.size = strlen(key.data) + 1;
- if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
+ if (aliasesdb->get(aliasesdb, &key, &val, 0) != 0) {
aliasesdb->close(aliasesdb);
return 0;
}
@@ -171,21 +167,17 @@ aliases_virtual_exist(struct smtpd *env, struct path *
key.data = strkey;
key.size = strlen(key.data) + 1;
- if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
- aliasesdb->close(aliasesdb);
- return 0;
- }
+ ret = aliasesdb->get(aliasesdb, &key, &val, 0);
}
aliasesdb->close(aliasesdb);
- return ret == 0 ? 1 : 0;
+ return (ret == 0);
}
int
aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
struct path *path)
{
- int ret;
DBT key;
DBT val;
DB *aliasesdb;
@@ -215,7 +207,7 @@ aliases_virtual_get(struct smtpd *env, struct aliasesl
key.data = strkey;
key.size = strlen(key.data) + 1;
- if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
+ if (aliasesdb->get(aliasesdb, &key, &val, 0) != 0) {
if (! bsnprintf(strkey, sizeof(strkey), "@%s", path->domain)) {
aliasesdb->close(aliasesdb);
@@ -227,7 +219,7 @@ aliases_virtual_get(struct smtpd *env, struct aliasesl
key.data = strkey;
key.size = strlen(key.data) + 1;
- if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
+ if (aliasesdb->get(aliasesdb, &key, &val, 0) != 0) {
aliasesdb->close(aliasesdb);
return 0;
}