1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

ldb:tools - return LDB_ERR_OPERATIONS_ERROR on generic errors

Use "return" when located in "main" for consistency ("exit" would do the
same).

The patchset has been discussed with Jelmer Vernooij and afterwards LDB
maintainer Simo Sorce.
This commit is contained in:
Matthias Dieter Wallnöfer 2011-02-01 20:34:44 +01:00
parent 5e06b21cc1
commit 8d80225afb
8 changed files with 20 additions and 19 deletions

View File

@ -313,7 +313,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
failed:
talloc_free(ret);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
return NULL;
}

View File

@ -43,7 +43,7 @@ static void usage(struct ldb_context *ldb)
printf("Usage: ldbadd <options> <ldif...>\n");
printf("Adds records to a ldb, reading ldif the specified list of files\n\n");
ldb_cmdline_help(ldb, "ldbadd", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
@ -127,7 +127,7 @@ int main(int argc, const char **argv)
f = fopen(fname, "r");
if (!f) {
perror(fname);
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
ret = process_file(ldb, f, &count);
fclose(f);

View File

@ -78,7 +78,7 @@ static void usage(struct ldb_context *ldb)
printf("Usage: ldbdel <options> <DN...>\n");
printf("Deletes records from a ldb\n\n");
ldb_cmdline_help(ldb, "ldbdel", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@ -98,13 +98,13 @@ int main(int argc, const char **argv)
if (options->argc < 1) {
usage(ldb);
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
return -1;
return LDB_ERR_OPERATIONS_ERROR;
}
for (i=0;i<options->argc;i++) {
@ -113,7 +113,7 @@ int main(int argc, const char **argv)
dn = ldb_dn_new(ldb, ldb, options->argv[i]);
if ( ! ldb_dn_validate(dn)) {
printf("Invalid DN format\n");
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
if (options->recursive) {
ret = ldb_delete_recursive(ldb, dn,req_ctrls);

View File

@ -291,7 +291,7 @@ static void usage(struct ldb_context *ldb)
{
printf("Usage: ldbedit <options> <expression> <attributes ...>\n");
ldb_cmdline_help(ldb, "ldbedit", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@ -328,20 +328,20 @@ int main(int argc, const char **argv)
basedn = ldb_dn_new(ldb, ldb, options->basedn);
if ( ! ldb_dn_validate(basedn)) {
printf("Invalid Base DN format\n");
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
}
req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
return -1;
return LDB_ERR_OPERATIONS_ERROR;
}
ret = ldb_search_ctrl(ldb, ldb, &result, basedn, options->scope, attrs, req_ctrls, "%s", expression);
if (ret != LDB_SUCCESS) {
printf("search failed - %s\n", ldb_errstring(ldb));
exit(1);
return ret;
}
if (result->count == 0) {

View File

@ -43,7 +43,7 @@ static void usage(struct ldb_context *ldb)
printf("Usage: ldbmodify <options> <ldif...>\n");
printf("Modifies a ldb based upon ldif change records\n\n");
ldb_cmdline_help(ldb, "ldbmodify", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
/*
@ -54,9 +54,10 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
struct ldb_ldif *ldif;
int ret = LDB_SUCCESS;
struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
return -1;
exit(LDB_ERR_OPERATIONS_ERROR);
}
while ((ldif = ldb_ldif_read_file(ldb, f))) {
@ -112,7 +113,7 @@ int main(int argc, const char **argv)
f = fopen(fname, "r");
if (!f) {
perror(fname);
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
ret = process_file(ldb, f, &count);
fclose(f);

View File

@ -41,7 +41,7 @@ static void usage(struct ldb_context *ldb)
printf("Usage: ldbrename [<options>] <olddn> <newdn>\n");
printf("Renames records in a ldb\n\n");
ldb_cmdline_help(ldb, "ldbmodify", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}

View File

@ -41,7 +41,7 @@ static void usage(struct ldb_context *ldb)
{
printf("Usage: ldbsearch <options> <expression> <attrs...>\n");
ldb_cmdline_help(ldb, "ldbsearch", stdout);
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
static int do_compare_msg(struct ldb_message **el1,
@ -299,7 +299,7 @@ int main(int argc, const char **argv)
basedn = ldb_dn_new(ldb, ldb, options->basedn);
if ( ! ldb_dn_validate(basedn)) {
fprintf(stderr, "Invalid Base DN format\n");
exit(1);
return LDB_ERR_OPERATIONS_ERROR;
}
}

View File

@ -396,7 +396,7 @@ static void usage(struct ldb_context *ldb)
printf(" --num-searches nsearches number of searches to do\n");
printf("\n");
printf("tests ldb API\n\n");
exit(1);
exit(LDB_ERR_OPERATIONS_ERROR);
}
int main(int argc, const char **argv)
@ -430,5 +430,5 @@ int main(int argc, const char **argv)
talloc_free(mem_ctx);
return 0;
return LDB_SUCCESS;
}