Skip to content
Snippets Groups Projects
Commit f25747c3 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: sieve - Use int for sieve_load() status result

parent cc171840
No related branches found
No related tags found
No related merge requests found
...@@ -377,15 +377,10 @@ sieve_run(struct sieve_binary *sbin, struct sieve_result *result, ...@@ -377,15 +377,10 @@ sieve_run(struct sieve_binary *sbin, struct sieve_result *result,
* Reading/writing sieve binaries * Reading/writing sieve binaries
*/ */
struct sieve_binary * int sieve_load(struct sieve_instance *svinst, const char *bin_path,
sieve_load(struct sieve_instance *svinst, const char *bin_path, struct sieve_binary **sbin_r, enum sieve_error *error_code_r)
enum sieve_error *error_code_r)
{ {
struct sieve_binary *sbin; return sieve_binary_open(svinst, bin_path, NULL, sbin_r, error_code_r);
if (sieve_binary_open(svinst, bin_path, NULL, &sbin, error_code_r) < 0)
return NULL;
return sbin;
} }
static int static int
......
...@@ -57,9 +57,8 @@ int sieve_compile(struct sieve_instance *svinst, const char *script_location, ...@@ -57,9 +57,8 @@ int sieve_compile(struct sieve_instance *svinst, const char *script_location,
*/ */
/* Loads the sieve binary indicated by the provided path. */ /* Loads the sieve binary indicated by the provided path. */
struct sieve_binary * int sieve_load(struct sieve_instance *svinst, const char *bin_path,
sieve_load(struct sieve_instance *svinst, const char *bin_path, struct sieve_binary **sbin_r, enum sieve_error *error_code_r);
enum sieve_error *error_code_r);
/* First tries to open the binary version of the specified script and if it does /* First tries to open the binary version of the specified script and if it does
not exist or if it contains errors, the script is (re-)compiled. Note that not exist or if it contains errors, the script is (re-)compiled. Note that
errors in the bytecode are caught only at runtime. errors in the bytecode are caught only at runtime.
......
...@@ -80,15 +80,13 @@ int main(int argc, char **argv) ...@@ -80,15 +80,13 @@ int main(int argc, char **argv)
sieve_enable_debug_extension(svinst); sieve_enable_debug_extension(svinst);
/* Dump binary */ /* Dump binary */
sbin = sieve_load(svinst, binfile, NULL); if (sieve_load(svinst, binfile, &sbin, NULL) < 0) {
if (sbin != NULL) {
sieve_tool_dump_binary_to(sbin,
(outfile == NULL ? "-" : outfile),
hexdump);
sieve_close(&sbin);
} else {
i_error("failed to load binary: %s", binfile); i_error("failed to load binary: %s", binfile);
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
} else {
sieve_tool_dump_binary_to(sbin, outfile == NULL ? "-" : outfile,
hexdump);
sieve_close(&sbin);
} }
sieve_tool_deinit(&sieve_tool); sieve_tool_deinit(&sieve_tool);
......
...@@ -75,8 +75,11 @@ bool testsuite_binary_save(struct sieve_binary *sbin, const char *name) ...@@ -75,8 +75,11 @@ bool testsuite_binary_save(struct sieve_binary *sbin, const char *name)
struct sieve_binary *testsuite_binary_load(const char *name) struct sieve_binary *testsuite_binary_load(const char *name)
{ {
struct sieve_instance *svinst = testsuite_sieve_instance; struct sieve_instance *svinst = testsuite_sieve_instance;
struct sieve_binary *sbin;
return sieve_load(svinst, if (sieve_load(svinst, t_strdup_printf("%s/%s", testsuite_binary_tmp,
t_strdup_printf("%s/%s", testsuite_binary_tmp, sieve_binfile_from_name(name)),
sieve_binfile_from_name(name)), NULL); &sbin, NULL) < 0)
return NULL;
return sbin;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.