diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-09-05 21:19:53 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-09-05 21:19:53 +0000 |
commit | 339f09405608ac5277fc0f43f459352967e7803d (patch) | |
tree | cc5d0348b4046acd4b81ef3cf5a881663da1b80b /src/or/config.c | |
parent | a34550667298dcff6cbd7333288d71808b800b33 (diff) | |
download | tor-339f09405608ac5277fc0f43f459352967e7803d.tar.gz tor-339f09405608ac5277fc0f43f459352967e7803d.zip |
Refactor some code and add some asserts based on scanner results.
svn:r16783
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/or/config.c b/src/or/config.c index 4f7c752464..92a4a0dbeb 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -4500,24 +4500,24 @@ write_configuration_file(const char *fname, or_options_t *options) int rename_old = 0, r; size_t len; - if (fname) { - switch (file_status(fname)) { - case FN_FILE: - old_val = read_file_to_str(fname, 0, NULL); - if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) { - rename_old = 1; - } - tor_free(old_val); - break; - case FN_NOENT: - break; - case FN_ERROR: - case FN_DIR: - default: - log_warn(LD_CONFIG, - "Config file \"%s\" is not a file? Failing.", fname); - return -1; - } + tor_assert(fname); + + switch (file_status(fname)) { + case FN_FILE: + old_val = read_file_to_str(fname, 0, NULL); + if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) { + rename_old = 1; + } + tor_free(old_val); + break; + case FN_NOENT: + break; + case FN_ERROR: + case FN_DIR: + default: + log_warn(LD_CONFIG, + "Config file \"%s\" is not a file? Failing.", fname); + return -1; } if (!(new_conf = options_dump(options, 1))) { |