From 204c43a22c89ed36d7a74b43124e6dc4340f462a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 22 Dec 2022 15:19:36 +0100 Subject: [PATCH] [tools] fixed settings getter generator use proper default error return values by type --- tools/update-settings-tests | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/update-settings-tests b/tools/update-settings-tests index 955ddc065..04834fef0 100755 --- a/tools/update-settings-tests +++ b/tools/update-settings-tests @@ -460,7 +460,7 @@ def write_getter_case(f, val): f.write('\t\tcase FreeRDP_' + val + ':\n') f.write('\t\t\treturn settings->' + val + ';\n\n') -def write_getter_body(f, values): +def write_getter_body(f, values, ret): f.write('{\n') f.write('\tWINPR_ASSERT(settings);\n\n') f.write('\tswitch (id)\n') @@ -470,7 +470,7 @@ def write_getter_body(f, values): write_getter_case(f, val) f.write('\t\tdefault:\n') f.write('\t\t\tWLog_ERR(TAG, "[%s] Invalid key index %" PRIuz " [%s|%s]", __FUNCTION__, id, freerdp_settings_get_name_for_key(id), freerdp_settings_get_type_name_for_key(id));\n') - f.write('\t\t\treturn FALSE;\n') + f.write('\t\t\treturn ' + ret + ';\n') f.write('\t}\n') f.write('}\n\n') @@ -490,11 +490,18 @@ def write_getter(f, entry_dict, entry_type, entry_name): f.write(' freerdp_settings_get_pointer_writable(rdpSettings* settings, size_t id)\n') else: f.write(' freerdp_settings_get_' + entry_name.lower() + '(const rdpSettings* settings, size_t id)\n') - write_getter_body(f, values) + if isString or isPointer: + ret = 'NULL'; + elif 'bool' in entry_name: + ret = 'FALSE'; + else: + ret = '0'; + + write_getter_body(f, values, ret) if isString: f.write('char* freerdp_settings_get_' + entry_name.lower() + '_writable(rdpSettings* settings, size_t id)\n') - write_getter_body(f, values) + write_getter_body(f, values, ret) def write_setter_case(f, val, isString, isPointer): f.write('\t\tcase FreeRDP_' + val + ':\n')