From 1fb1f6bc0dad00d1eb2d1e2aff34e9d3b2714421 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Fri, 17 Jan 2014 10:30:37 +1300 Subject: lib/param: handle non-constant strings properly by passing in a memory context Signed-off-by: Garming Sam Change-Id: Ic6bb1c709defd2b0f35fc7b877da0badca385776 Reviewed-by: Andrew Bartlett Reviewed-by: Nadezhda Ivanova --- script/generate_param.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'script') diff --git a/script/generate_param.py b/script/generate_param.py index 4e04b3a45bf..7df097ec3ed 100644 --- a/script/generate_param.py +++ b/script/generate_param.py @@ -177,7 +177,7 @@ def make_lib_proto(path_in, path_out): continue output_string = "" - if parameter['constant'] or parameter['type'] == 'string': + if parameter['constant']: output_string += 'const ' param_type = mapping.get(parameter['type']) if param_type is None: @@ -186,12 +186,20 @@ def make_lib_proto(path_in, path_out): output_string += "lpcfg_%s" % parameter['function'] - if parameter['context'] == 'G': - output_string += '(struct loadparm_context *);\n' - elif parameter['context'] == 'S': - output_string += '(struct loadparm_service *, struct loadparm_service *);\n' + if parameter['type'] == 'string' and not parameter['constant']: + if parameter['context'] == 'G': + output_string += '(struct loadparm_context *, TALLOC_CTX *ctx);\n' + elif parameter['context'] == 'S': + output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n' + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) else: - raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) + if parameter['context'] == 'G': + output_string += '(struct loadparm_context *);\n' + elif parameter['context'] == 'S': + output_string += '(struct loadparm_service *, struct loadparm_service *);\n' + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) file_out.write(output_string) @@ -277,9 +285,6 @@ def make_s3_param(path_in, path_out): continue if parameter['context'] != 'G': continue - # STRING isn't handle yet properly - if parameter['type'] == 'string' and not parameter['constant']: - continue output_string = "\t" if parameter['constant'] or parameter['type'] == 'string': output_string += 'const ' @@ -288,7 +293,10 @@ def make_s3_param(path_in, path_out): raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) output_string += param_type - output_string += " (*%s)(void);\n" % parameter['function'] + if parameter['type'] == 'string' and not parameter['constant']: + output_string += " (*%s)(TALLOC_CTX *);\n" % parameter['function'] + else: + output_string += " (*%s)(void);\n" % parameter['function'] file_out.write(output_string) file_out.write("};\n") @@ -321,9 +329,6 @@ def make_s3_param_ctx_table(path_in, path_out): continue if parameter['context'] != 'G': continue - # STRING isn't handle yet properly - if parameter['type'] == 'string' and not parameter['constant']: - continue output_string = "\t.%s" % parameter['function'] output_string += " = lp_%s,\n" % parameter['function'] file_out.write(output_string) -- cgit v1.2.1