[PATCH 2/7] ldb:ldbdel tool - use LDB result constants for consistency

Matthias Dieter Wallnöfer mdw at samba.org
Tue Jan 18 00:13:10 MST 2011


Simo,

please consider the code part from "main":
> @@ -116,11 +116,11 @@ int main(int argc, const char **argv)
>   			ret = ldb_delete_recursive(ldb, dn,req_ctrls);
>   		} else {
>   			ret = ldb_delete_ctrl(ldb, dn,req_ctrls);
> -			if (ret == 0) {
> +			if (ret == LDB_SUCCESS) {
>   				printf("Deleted 1 record\n");
>   			}
>   		}
> -		if (ret != 0) {
> +		if (ret != LDB_SUCCESS) {
>   			printf("delete of '%s' failed - (%s) %s\n",
>   			       ldb_dn_get_linearized(dn),
>   			       ldb_strerror(ret),
>    
"ldb_delete_recursive" previously returned 0 or -1 while 
"ldb_delete_ctrl" always returned an LDB result. Therefore I thought to 
adapt both to return a LDB result. But I'm open for discussions to don't 
return this LDB result code as an exit code, but to convert it somehow.

Cheers,
Matthias

simo wrote:
> On Mon, 2011-01-17 at 22:45 +0100, Matthias Dieter Wallnöfer wrote:
>    
>>          ret = ldb_search(ldb, ldb,&res, dn, LDB_SCOPE_SUBTREE, attrs,
>> "distinguishedName=*");
>> -       if (ret != LDB_SUCCESS) return -1;
>> +       if (ret != LDB_SUCCESS) return ret;
>>
>>      
> The return code from ldb_delete_recursive() is returned directly to main
> and from there to the userspace that called ldbdel
>
> This patch would change the return error codes of the ldbdel tool.
>
> I am not sure it is a good idea.
>
> In general tool do not return LDB_ERR_*/LDB_SUCCESS on purpose, as they
> return internal utility error codes to be returned to the user space.
>
> What do we gain with these patches ?
>
> Simo.
>
>    



More information about the samba-technical mailing list