summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2021-04-07 15:37:35 +0000
committerJeremy Allison <jra@samba.org>2021-04-19 18:18:31 +0000
commitea47224f6530f15f92c9e122ae535720a685306c (patch)
treec92fabd11f557bf8f5bef8cc78473ca4d86e79b5 /source3/rpc_client
parent43dcca632a221f6469f0fc0c34c714b7765f1f3b (diff)
downloadsamba-ea47224f6530f15f92c9e122ae535720a685306c.tar.gz
printing: Make winreg_get_printer() a bit easier to understand
This is more lines, but the FILL_STRING macro did not really gain much in clarity for me. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_winreg_spoolss.c68
1 files changed, 46 insertions, 22 deletions
diff --git a/source3/rpc_client/cli_winreg_spoolss.c b/source3/rpc_client/cli_winreg_spoolss.c
index 051b6665fde..b84bbae2ceb 100644
--- a/source3/rpc_client/cli_winreg_spoolss.c
+++ b/source3/rpc_client/cli_winreg_spoolss.c
@@ -38,16 +38,6 @@
#define TOP_LEVEL_CONTROL_KEY "SYSTEM\\CurrentControlSet\\Control\\Print"
#define TOP_LEVEL_CONTROL_FORMS_KEY TOP_LEVEL_CONTROL_KEY "\\Forms"
-#define FILL_STRING(mem_ctx, in, out) \
- do { \
- if (in && strlen(in)) { \
- out = talloc_strdup(mem_ctx, in); \
- } else { \
- out = talloc_strdup(mem_ctx, ""); \
- } \
- W_ERROR_HAVE_NO_MEMORY(out); \
- } while (0);
-
#define CHECK_ERROR(result) \
if (W_ERROR_IS_OK(result)) continue; \
if (W_ERROR_EQUAL(result, WERR_NOT_FOUND)) result = WERR_OK; \
@@ -1549,23 +1539,57 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
goto done;
}
+ result = WERR_NOT_ENOUGH_MEMORY;
+
info2 = talloc_zero(tmp_ctx, struct spoolss_PrinterInfo2);
if (info2 == NULL) {
- result = WERR_NOT_ENOUGH_MEMORY;
goto done;
}
- FILL_STRING(info2, "", info2->servername);
- FILL_STRING(info2, "", info2->printername);
- FILL_STRING(info2, "", info2->sharename);
- FILL_STRING(info2, "", info2->portname);
- FILL_STRING(info2, "", info2->drivername);
- FILL_STRING(info2, "", info2->comment);
- FILL_STRING(info2, "", info2->location);
- FILL_STRING(info2, "", info2->sepfile);
- FILL_STRING(info2, "", info2->printprocessor);
- FILL_STRING(info2, "", info2->datatype);
- FILL_STRING(info2, "", info2->parameters);
+ info2->servername = talloc_strdup(info2, "");
+ if (info2->servername == NULL) {
+ goto done;
+ }
+ info2->printername = talloc_strdup(info2, "");
+ if (info2->printername == NULL) {
+ goto done;
+ }
+ info2->sharename = talloc_strdup(info2, "");
+ if (info2->sharename == NULL) {
+ goto done;
+ }
+ info2->portname = talloc_strdup(info2, "");
+ if (info2->portname == NULL) {
+ goto done;
+ }
+ info2->drivername = talloc_strdup(info2, "");
+ if (info2->drivername == NULL) {
+ goto done;
+ }
+ info2->comment = talloc_strdup(info2, "");
+ if (info2->comment == NULL) {
+ goto done;
+ }
+ info2->location = talloc_strdup(info2, "");
+ if (info2->location == NULL) {
+ goto done;
+ }
+ info2->sepfile = talloc_strdup(info2, "");
+ if (info2->sepfile == NULL) {
+ goto done;
+ }
+ info2->printprocessor = talloc_strdup(info2, "");
+ if (info2->printprocessor == NULL) {
+ goto done;
+ }
+ info2->datatype = talloc_strdup(info2, "");
+ if (info2->datatype == NULL) {
+ goto done;
+ }
+ info2->parameters = talloc_strdup(info2, "");
+ if (info2->parameters == NULL) {
+ goto done;
+ }
for (i = 0; i < num_values; i++) {
enum_value.value_name = enum_names[i];