{"thread":{"id":"27187","subject":"[PATCH] run-command.c: Fix unused variables warning with gcc 4.6","startedAt":"2011-04-26T12:28:14Z","lastAt":"2011-04-27T01:16:14Z","messageCount":5,"participants":["Michael Schubert","Michael J Gruber","Andreas Ericsson","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166376","messageId":"4DB6BA5E.3040306@elegosoft.com","threadId":"27187","inReplyTo":null,"subject":"[PATCH] run-command.c: Fix unused variables warning with gcc 4.6","fromName":"Michael Schubert","fromEmail":"mschub@elegosoft.com","sentAt":"2011-04-26T12:28:14Z","receivedAt":"2011-04-26T12:28:14Z","isPatch":true,"sender":{"key":"mschub@elegosoft.com","avatar":null},"body":"As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Remove all\nunused variables to prevent those warnings.\n\nSigned-off-by: Michael Schubert <mschub@elegosoft.com>\n---\n run-command.c |   10 ++++------\n 1 files changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex f91e446..6e0be54 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -67,21 +67,19 @@ static int child_notifier = -1;\n\n static void notify_parent(void)\n {\n-\tssize_t unused;\n-\tunused = write(child_notifier, \"\", 1);\n+\twrite(child_notifier, \"\", 1);\n }\n\n static NORETURN void die_child(const char *err, va_list params)\n {\n \tchar msg[4096];\n-\tssize_t unused;\n \tint len = vsnprintf(msg, sizeof(msg), err, params);\n \tif (len > sizeof(msg))\n \t\tlen = sizeof(msg);\n\n-\tunused = write(child_err, \"fatal: \", 7);\n-\tunused = write(child_err, msg, len);\n-\tunused = write(child_err, \"\\n\", 1);\n+\twrite(child_err, \"fatal: \", 7);\n+\twrite(child_err, msg, len);\n+\twrite(child_err, \"\\n\", 1);\n \texit(128);\n }\n #endif\n-- \n1.7.4.4\n"},{"id":"166377","messageId":"4DB6C501.6000705@drmicha.warpmail.net","threadId":"27187","inReplyTo":"4DB6BA5E.3040306@elegosoft.com","subject":"Re: [PATCH] run-command.c: Fix unused variables warning with gcc 4.6","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-04-26T13:13:37Z","receivedAt":"2011-04-26T13:13:37Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Michael Schubert venit, vidit, dixit 26.04.2011 14:28:\n> As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Remove all\n> unused variables to prevent those warnings.\n> \n> Signed-off-by: Michael Schubert <mschub@elegosoft.com>\n> ---\n>  run-command.c |   10 ++++------\n>  1 files changed, 4 insertions(+), 6 deletions(-)\n> \n> diff --git a/run-command.c b/run-command.c\n> index f91e446..6e0be54 100644\n> --- a/run-command.c\n> +++ b/run-command.c\n> @@ -67,21 +67,19 @@ static int child_notifier = -1;\n> \n>  static void notify_parent(void)\n>  {\n> -\tssize_t unused;\n> -\tunused = write(child_notifier, \"\", 1);\n> +\twrite(child_notifier, \"\", 1);\n>  }\n> \n>  static NORETURN void die_child(const char *err, va_list params)\n>  {\n>  \tchar msg[4096];\n> -\tssize_t unused;\n>  \tint len = vsnprintf(msg, sizeof(msg), err, params);\n>  \tif (len > sizeof(msg))\n>  \t\tlen = sizeof(msg);\n> \n> -\tunused = write(child_err, \"fatal: \", 7);\n> -\tunused = write(child_err, msg, len);\n> -\tunused = write(child_err, \"\\n\", 1);\n> +\twrite(child_err, \"fatal: \", 7);\n> +\twrite(child_err, msg, len);\n> +\twrite(child_err, \"\\n\", 1);\n>  \texit(128);\n>  }\n>  #endif\n\ngit log -S\"unused\" origin/master run-command.c\n\nshows that these dummies were introduced for a reason. How do you\ninvalidate that?\n\nMichael\n"},{"id":"166379","messageId":"4DB6C83A.4040900@elegosoft.com","threadId":"27187","inReplyTo":"4DB6C501.6000705@drmicha.warpmail.net","subject":"Re: [PATCH] run-command.c: Fix unused variables warning with gcc 4.6","fromName":"Michael Schubert","fromEmail":"mschub@elegosoft.com","sentAt":"2011-04-26T13:27:22Z","receivedAt":"2011-04-26T13:27:22Z","isPatch":true,"sender":{"key":"mschub@elegosoft.com","avatar":null},"body":"On 04/26/2011 03:13 PM, Michael J Gruber wrote:\n> Michael Schubert venit, vidit, dixit 26.04.2011 14:28:\n>> As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Remove all\n>> unused variables to prevent those warnings.\n>>\n>> Signed-off-by: Michael Schubert <mschub@elegosoft.com>\n>> ---\n>>  run-command.c |   10 ++++------\n>>  1 files changed, 4 insertions(+), 6 deletions(-)\n>>\n>> diff --git a/run-command.c b/run-command.c\n>> index f91e446..6e0be54 100644\n>> --- a/run-command.c\n>> +++ b/run-command.c\n>> @@ -67,21 +67,19 @@ static int child_notifier = -1;\n>>\n>>  static void notify_parent(void)\n>>  {\n>> -\tssize_t unused;\n>> -\tunused = write(child_notifier, \"\", 1);\n>> +\twrite(child_notifier, \"\", 1);\n>>  }\n>>\n>>  static NORETURN void die_child(const char *err, va_list params)\n>>  {\n>>  \tchar msg[4096];\n>> -\tssize_t unused;\n>>  \tint len = vsnprintf(msg, sizeof(msg), err, params);\n>>  \tif (len > sizeof(msg))\n>>  \t\tlen = sizeof(msg);\n>>\n>> -\tunused = write(child_err, \"fatal: \", 7);\n>> -\tunused = write(child_err, msg, len);\n>> -\tunused = write(child_err, \"\\n\", 1);\n>> +\twrite(child_err, \"fatal: \", 7);\n>> +\twrite(child_err, msg, len);\n>> +\twrite(child_err, \"\\n\", 1);\n>>  \texit(128);\n>>  }\n>>  #endif\n> \n> git log -S\"unused\" origin/master run-command.c\n> \n> shows that these dummies were introduced for a reason. How do you\n> invalidate that?\n\nSorry, just missed that.\n"},{"id":"166380","messageId":"4DB6CC6D.1030105@op5.se","threadId":"27187","inReplyTo":"4DB6C83A.4040900@elegosoft.com","subject":"Re: [PATCH] run-command.c: Fix unused variables warning with gcc 4.6","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2011-04-26T13:45:17Z","receivedAt":"2011-04-26T13:45:17Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 04/26/2011 03:27 PM, Michael Schubert wrote:\n> On 04/26/2011 03:13 PM, Michael J Gruber wrote:\n>> Michael Schubert venit, vidit, dixit 26.04.2011 14:28:\n>>> As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Remove all\n>>> unused variables to prevent those warnings.\n>>>\n>>> Signed-off-by: Michael Schubert<mschub@elegosoft.com>\n>>> ---\n>>>   run-command.c |   10 ++++------\n>>>   1 files changed, 4 insertions(+), 6 deletions(-)\n>>>\n>>> diff --git a/run-command.c b/run-command.c\n>>> index f91e446..6e0be54 100644\n>>> --- a/run-command.c\n>>> +++ b/run-command.c\n>>> @@ -67,21 +67,19 @@ static int child_notifier = -1;\n>>>\n>>>   static void notify_parent(void)\n>>>   {\n>>> -\tssize_t unused;\n>>> -\tunused = write(child_notifier, \"\", 1);\n>>> +\twrite(child_notifier, \"\", 1);\n>>>   }\n>>>\n>>>   static NORETURN void die_child(const char *err, va_list params)\n>>>   {\n>>>   \tchar msg[4096];\n>>> -\tssize_t unused;\n>>>   \tint len = vsnprintf(msg, sizeof(msg), err, params);\n>>>   \tif (len>  sizeof(msg))\n>>>   \t\tlen = sizeof(msg);\n>>>\n>>> -\tunused = write(child_err, \"fatal: \", 7);\n>>> -\tunused = write(child_err, msg, len);\n>>> -\tunused = write(child_err, \"\\n\", 1);\n>>> +\twrite(child_err, \"fatal: \", 7);\n>>> +\twrite(child_err, msg, len);\n>>> +\twrite(child_err, \"\\n\", 1);\n>>>   \texit(128);\n>>>   }\n>>>   #endif\n>>\n>> git log -S\"unused\" origin/master run-command.c\n>>\n>> shows that these dummies were introduced for a reason. How do you\n>> invalidate that?\n> \n> Sorry, just missed that.\n> \n\nA better solution than reverting the prettifying commit\nebec842773932e6f853acac70c80f84209b5f83e would be to rework it to use\nlogical AND instead of logical OR, as the AND-chain won't short-circuit\nthe statement chain early and prevent output from being printed when\nwrite() returns non-zero. When it *does* return zero, it's likely due\nto problems on the receiving ends, making further writing totally\npointless anyway.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"166424","messageId":"20110427011614.GA14181@elie","threadId":"27187","inReplyTo":"4DB6BA5E.3040306@elegosoft.com","subject":"Re: [PATCH] run-command.c: Fix unused variables warning with gcc 4.6","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T01:16:14Z","receivedAt":"2011-04-27T01:16:14Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Michael,\n\nMichael Schubert wrote:\n\n> As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Remove all\n> unused variables to prevent those warnings.\n\nAs the other Michael mentioned, this patch replaces one warning with\nanother.  You might like a111eb7 (run-command: handle short writes and\nEINTR in die_child, 2011-04-20, aka jn/run-command-error-failure in\n\"pu\"), which eliminates both.\n\nAndreas, a patch on top to short-circuit away the later writes on\nerror doesn't sound bad to me if you'd like, though it seems like a\nbit of an edge case.\n\nThanks, all.\nJonathan\n"}]}