{"thread":{"id":"6641","subject":"[PATCH] fix use of sometimes uninitialized variable 'msg'","startedAt":"2007-02-03T16:49:22Z","lastAt":"2007-02-03T23:21:56Z","messageCount":11,"participants":["Michael Coleman","Mike Coleman","Lars Hjemli","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"33456","messageId":"11705213633209-git-send-email-tutufan@gmail.com","threadId":"6641","inReplyTo":null,"subject":"[PATCH] fix use of sometimes uninitialized variable 'msg'","fromName":"Michael Coleman","fromEmail":"tutufan@gmail.com","sentAt":"2007-02-03T16:49:22Z","receivedAt":"2007-02-03T16:49:22Z","isPatch":true,"sender":{"key":"tutufan@gmail.com","avatar":null},"body":""},{"id":"33457","messageId":"11705213662728-git-send-email-tutufan@gmail.com","threadId":"6641","inReplyTo":"11705213633209-git-send-email-tutufan@gmail.com","subject":"[PATCH] fix uninitialized use of msg buffer","fromName":"Michael Coleman","fromEmail":"tutufan@gmail.com","sentAt":"2007-02-03T16:49:23Z","receivedAt":"2007-02-03T16:49:23Z","isPatch":true,"sender":{"key":"tutufan@gmail.com","avatar":null},"body":"---\n builtin-branch.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex d60690b..ac64b99 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -315,7 +315,7 @@ static void create_branch(const char *name, const char *start_name,\n \tstruct ref_lock *lock;\n \tstruct commit *commit;\n \tunsigned char sha1[20];\n-\tchar ref[PATH_MAX], msg[PATH_MAX + 20];\n+\tchar ref[PATH_MAX], msg[PATH_MAX + 20] = { 0 };\n \n \tsnprintf(ref, sizeof ref, \"refs/heads/%s\", name);\n \tif (check_ref_format(ref))\n-- \n1.5.0.rc3\n"},{"id":"33459","messageId":"loom.20070203T180123-680@post.gmane.org","threadId":"6641","inReplyTo":"11705213633209-git-send-email-tutufan@gmail.com","subject":"Re: [PATCH] fix use of sometimes uninitialized variable 'msg'","fromName":"Mike Coleman","fromEmail":"tutufan@gmail.com","sentAt":"2007-02-03T17:05:30Z","receivedAt":"2007-02-03T17:05:30Z","isPatch":true,"sender":{"key":"tutufan@gmail.com","avatar":null},"body":"Michael Coleman <tutufan <at> gmail.com> writes:\n> \n> \n> \n\nOops--I didn't realize a header email was going to be sent out, too.  Not quite\nsure what happened there.  When I tested it before, I thought only one email got\nsent.\n\nMike\n"},{"id":"33464","messageId":"11705266492308-git-send-email-hjemli@gmail.com","threadId":"6641","inReplyTo":"11705213662728-git-send-email-tutufan@gmail.com","subject":"[PATCH] builtin-branch: be prepared for ref-logging","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-02-03T18:17:29Z","receivedAt":"2007-02-03T18:17:29Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"The test for reflog parameter to create_branch() should also have tested\nfor log_all_ref_updates. But there is no good reason not to prepare a\nreflog message, so lets just do it.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nIf log_all_ref_updates==1 then the reflog will get an empty message with \nyour patch. That is better than using an uninitialized message, but I think\nit's still better to just prepare a proper message.\n\n\n builtin-branch.c |    7 +------\n 1 files changed, 1 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex d60690b..16b589e 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -342,12 +342,7 @@ static void create_branch(const char *name, const char *start_name,\n \tif (!lock)\n \t\tdie(\"Failed to lock ref for update: %s.\", strerror(errno));\n \n-\tif (reflog) {\n-\t\tlog_all_ref_updates = 1;\n-\t\tsnprintf(msg, sizeof msg, \"branch: Created from %s\",\n-\t\t\t start_name);\n-\t}\n-\n+\tsnprintf(msg, sizeof msg, \"branch: Created from %s\", start_name);\n \tif (write_ref_sha1(lock, sha1, msg) < 0)\n \t\tdie(\"Failed to write ref: %s.\", strerror(errno));\n }\n-- \n1.5.0.rc2.ge4b0e\n"},{"id":"33466","messageId":"11705277471962-git-send-email-hjemli@gmail.com","threadId":"6641","inReplyTo":"11705213662728-git-send-email-tutufan@gmail.com","subject":"[PATCH] builtin-branch: be prepared for ref-logging","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-02-03T18:35:47Z","receivedAt":"2007-02-03T18:35:47Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"The test for reflog parameter to create_branch() should also have tested\nfor log_all_ref_updates. But there is no good reason not to prepare a\nreflog message, so lets just do it.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nSorry, the previous patch was obviously no good, since it didn't honour\nthe case where (reflog==1 && log_all_ref_updates==0)\n\nThis one should be better.\n\n\n builtin-branch.c |    6 ++----\n 1 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex d60690b..a8c8c98 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -342,12 +342,10 @@ static void create_branch(const char *name, const char *start_name,\n \tif (!lock)\n \t\tdie(\"Failed to lock ref for update: %s.\", strerror(errno));\n \n-\tif (reflog) {\n+\tif (reflog)\n \t\tlog_all_ref_updates = 1;\n-\t\tsnprintf(msg, sizeof msg, \"branch: Created from %s\",\n-\t\t\t start_name);\n-\t}\n \n+\tsnprintf(msg, sizeof msg, \"branch: Created from %s\", start_name);\n \tif (write_ref_sha1(lock, sha1, msg) < 0)\n \t\tdie(\"Failed to write ref: %s.\", strerror(errno));\n }\n-- \n1.5.0.rc2.ge4b0e\n"},{"id":"33467","messageId":"7vzm7v5aw7.fsf@assigned-by-dhcp.cox.net","threadId":"6641","inReplyTo":"11705266492308-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-03T18:55:20Z","receivedAt":"2007-02-03T18:55:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> The test for reflog parameter to create_branch() should also have tested\n> for log_all_ref_updates. But there is no good reason not to prepare a\n> reflog message, so lets just do it.\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n> ---\n>\n> If log_all_ref_updates==1 then the reflog will get an empty message with \n> your patch. That is better than using an uninitialized message, but I think\n> it's still better to just prepare a proper message.\n\nTrue, but don't you still need to set log_all_ref_updates while\nyou call write_ref_sha1() for that ref in order to make sure\nthat log_ref_write() sets O_CREAT in oflags?\n"},{"id":"33472","messageId":"7vr6t73tsi.fsf@assigned-by-dhcp.cox.net","threadId":"6641","inReplyTo":"11705277471962-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-03T19:50:05Z","receivedAt":"2007-02-03T19:50:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> The test for reflog parameter to create_branch() should also have tested\n> for log_all_ref_updates. But there is no good reason not to prepare a\n> reflog message, so lets just do it.\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n> ---\n>\n> Sorry, the previous patch was obviously no good, since it didn't honour\n> the case where (reflog==1 && log_all_ref_updates==0)\n\nAh, I did not see your fix-up patch before I sent out my\ncomments.\n\nFunny thing is that I thought I fixed this already, but\napparently I didn't.  It could have been one of my \"fixing in\nworking tree, sending out a patch to the list for comments and\nthen forgetting to apply it\".  Maybe not.\n\nIn any case, thanks for the fix.\n"},{"id":"33477","messageId":"8c5c35580702031238i612acda0p26aba8e3df747b1a@mail.gmail.com","threadId":"6641","inReplyTo":"7vr6t73tsi.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-02-03T20:38:56Z","receivedAt":"2007-02-03T20:38:56Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 2/3/07, Junio C Hamano <junkio@cox.net> wrote:\n> Funny thing is that I thought I fixed this already\n\nInfact, you did:\n\n  http://article.gmane.org/gmane.comp.version-control.git/37197\n\nDon't know what happend to this one...\n\n-- \nlarsh\n"},{"id":"33481","messageId":"7v64aj3qtu.fsf@assigned-by-dhcp.cox.net","threadId":"6641","inReplyTo":"8c5c35580702031238i612acda0p26aba8e3df747b1a@mail.gmail.com","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-03T20:54:05Z","receivedAt":"2007-02-03T20:54:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> On 2/3/07, Junio C Hamano <junkio@cox.net> wrote:\n>> Funny thing is that I thought I fixed this already\n>\n> Infact, you did:\n>\n>  http://article.gmane.org/gmane.comp.version-control.git/37197\n>\n> Don't know what happend to this one...\n\nThanks, and I do think that patch is better ;-).\n"},{"id":"33485","messageId":"8c5c35580702031320m2cdf2087k5e2de24d2ec0504@mail.gmail.com","threadId":"6641","inReplyTo":"7v64aj3qtu.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-02-03T21:20:10Z","receivedAt":"2007-02-03T21:20:10Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 2/3/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Lars Hjemli\" <hjemli@gmail.com> writes:\n>\n> > On 2/3/07, Junio C Hamano <junkio@cox.net> wrote:\n> >> Funny thing is that I thought I fixed this already\n> >\n> > Infact, you did:\n> >\n> >  http://article.gmane.org/gmane.comp.version-control.git/37197\n> >\n> > Don't know what happend to this one...\n>\n> Thanks, and I do think that patch is better ;-).\n\nAgreed\n\n-- \nlarsh\n"},{"id":"33500","messageId":"7v1wl63jzf.fsf@assigned-by-dhcp.cox.net","threadId":"6641","inReplyTo":"8c5c35580702031238i612acda0p26aba8e3df747b1a@mail.gmail.com","subject":"Re: [PATCH] builtin-branch: be prepared for ref-logging","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-03T23:21:56Z","receivedAt":"2007-02-03T23:21:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> On 2/3/07, Junio C Hamano <junkio@cox.net> wrote:\n>> Funny thing is that I thought I fixed this already\n>\n> Infact, you did:\n>\n>  http://article.gmane.org/gmane.comp.version-control.git/37197\n>\n> Don't know what happend to this one...\n\nIt turns out that I was missing another patch from the same day.\n\n\thttp://article.gmane.org/gmane.comp.version-control.git/37238\n\nI guess we need a patch secretary whose job is to keep track of\nall the patches sent to the list and make sure nothing stays in\nlimbo X-<.\n"}]}