diff options
author | Russell Belfer <rb@github.com> | 2014-04-30 10:57:42 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-02 09:21:33 -0700 |
commit | 702efc891f2a620f10998062ba0c00b34100f632 (patch) | |
tree | e80132037df687837a40b5c3d8f1d6a079d35e43 /src/diff.c | |
parent | 9c8ed4999740e921ecc2966bbcd0dbcfc725f59a (diff) | |
download | libgit2-702efc891f2a620f10998062ba0c00b34100f632.tar.gz |
Make init_options fns use unsigned ints and macro
Use an unsigned int for the version and add a helper macro so the
code is simplified (and so the error message is a common string).
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/diff.c b/src/diff.c index 26e671dce..56f333f76 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1628,29 +1628,26 @@ int git_diff_commit_as_email( return error; } -int git_diff_init_options(git_diff_options* opts, unsigned int version) +int git_diff_init_options(git_diff_options *opts, unsigned int version) { - git_diff_options o = GIT_DIFF_OPTIONS_INIT; - if (version != o.version) - return diff_options_bad_version(version, "git_diff_options"); - memcpy(opts, &o, sizeof(o)); + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_options, GIT_DIFF_OPTIONS_INIT); return 0; } -int git_diff_find_init_options(git_diff_find_options* opts, unsigned int version) +int git_diff_find_init_options( + git_diff_find_options *opts, unsigned int version) { - git_diff_find_options o = GIT_DIFF_FIND_OPTIONS_INIT; - if (version != o.version) - return diff_options_bad_version(version, "git_diff_find_options"); - memcpy(opts, &o, sizeof(o)); + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_find_options, GIT_DIFF_FIND_OPTIONS_INIT); return 0; } -int git_diff_format_email_init_options(git_diff_format_email_options* opts, unsigned int version) +int git_diff_format_email_init_options( + git_diff_format_email_options *opts, unsigned int version) { - git_diff_format_email_options o = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; - if (version != o.version) - return diff_options_bad_version(version, "git_diff_format_email_options"); - memcpy(opts, &o, sizeof(o)); + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_format_email_options, + GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT); return 0; } |