Hi,
Looking at the man page for the db get function, it return -1 on error
and 1 if the key is not present and finally 0 on success.
In the aliases_exist() function there is the check for the errors there
yes and close of the BD regardless if errors are there or not as it
needs to be close anyway.
Then the function needs to return and want to return 1 on success and 0
in any other cases, errors or not present key regardless.
So, wouldn't it be cleaner to have it shortened to this then?
This makes it more readable and shorten the code as well with the same
outcome of returning1 only on success as intended.
Just something I came across reading it tonight. The possible error
check are done in both cases this way.
Am I missing something obvious that I am not thinking about?
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 06:29:20 -0000
@@ -64,10 +64,7 @@ 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;