{"thread":{"id":"23399","subject":"[PATCH] Let check_preimage() use memset() to initialize \"struct checkout\"","startedAt":"2010-04-09T20:08:35Z","lastAt":"2010-04-09T20:08:35Z","messageCount":1,"participants":["Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"139070","messageId":"4BBF8943.40407@web.de","threadId":"23399","inReplyTo":null,"subject":"[PATCH] Let check_preimage() use memset() to initialize \"struct checkout\"","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-04-09T20:08:35Z","receivedAt":"2010-04-09T20:08:35Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Every code site except check_preimage() uses either memset() or declares\na static instance of \"struct checkout\" to achieve proper initialization.\nLets use memset() instead of explicit initialization of all members here\ntoo to be on the safe side in case this structure is expanded someday.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\n builtin/apply.c |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex ec755ac..d56cabf 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2821,11 +2821,8 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s\n \t\tif (stat_ret < 0) {\n \t\t\tstruct checkout costate;\n \t\t\t/* checkout */\n+\t\t\tmemset(&costate, 0, sizeof(costate));\n \t\t\tcostate.base_dir = \"\";\n-\t\t\tcostate.base_dir_len = 0;\n-\t\t\tcostate.force = 0;\n-\t\t\tcostate.quiet = 0;\n-\t\t\tcostate.not_new = 0;\n \t\t\tcostate.refresh_cache = 1;\n \t\t\tif (checkout_entry(*ce, &costate, NULL) ||\n \t\t\t    lstat(old_name, st))\n-- \n1.7.0.3.517.g0017\n"}]}