On Thu, Aug 28, 2014 at 11:49:38AM +0200, Pavel Reichl wrote:
>>Hello,
>>
>>sorry for late reply. I guess your approach will definitely save some
>>lines of code and some CPU cycles.
>>
>>I just must get used to the idea that macros are not considered evil in
>>out environment. :-)
>>
>>Please see attached patch.
>>
>>Regards,
>>
>>Pavel Reichl
>>
I have one small comment, sorry for coming late into the thread...
-errno_t sss_ldb_search(struct ldb_context *ldb, TALLOC_CTX
*mem_ctx,
- struct ldb_result **_result, struct ldb_dn *base,
- enum ldb_scope scope, const char * const *attrs,
- const char *exp_fmt, ...) SSS_ATTRIBUTE_PRINTF(7, 8);
-
/* functions that modify the databse
* they have to be called within a transaction
* See sysdb_transaction_send()/_recv() */
@@ -901,4 +896,16 @@ errno_t sysdb_gpo_get_gpos(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
struct ldb_result **_result);
+#define SSS_LDB_SEARCH(ret, ldb, mem_ctx, _result, base, scope, attrs, \
+ exp_fmt, ...) do { \
+ int lret; \
Can you rename the variable "lret" here? Calling it "lret" might clash
with
some other variable from outer scope..
Maybe "_sls_lret" ? (_sss_ldb_search_lret)
+
\
+ lret = ldb_search(ldb, mem_ctx, _result, base, scope, attrs, exp_fmt, \
+ ##__VA_ARGS__); \
+ ret = sysdb_error_to_errno(lret); \
+ if (ret == EOK && (*_result)->count == 0) { \
+ ret = ENOENT; \
+ } \
+} while(0)
+