{"thread":{"id":"529","subject":"[PATCH] Really *do* nothing in while loop","startedAt":"2005-05-08T09:34:40Z","lastAt":"2005-05-08T21:35:23Z","messageCount":9,"participants":["Thomas Glanzmann","Michael Tokarev","James Purser","jdow","Junio C Hamano","Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2766","messageId":"20050508093440.GA9873@cip.informatik.uni-erlangen.de","threadId":"529","inReplyTo":null,"subject":"[PATCH] Really *do* nothing in while loop","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2005-05-08T09:34:40Z","receivedAt":"2005-05-08T09:34:40Z","isPatch":true,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"[PATCH] Really *do* nothing in while loop\n\nSigned-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>\n\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -335,7 +335,7 @@\n \tstream.next_in = hdr;\n \tstream.avail_in = hdrlen;\n \twhile (deflate(&stream, 0) == Z_OK)\n-\t\t/* nothing */\n+\t\t/* nothing */;\n \n \t/* Then the data itself.. */\n \tstream.next_in = buf;\n"},{"id":"2767","messageId":"427DE086.40307@tls.msk.ru","threadId":"529","inReplyTo":"20050508093440.GA9873@cip.informatik.uni-erlangen.de","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Michael Tokarev","fromEmail":"mjt@tls.msk.ru","sentAt":"2005-05-08T09:48:54Z","receivedAt":"2005-05-08T09:48:54Z","isPatch":true,"sender":{"key":"mjt@tls.msk.ru","avatar":null},"body":"Thomas Glanzmann wrote:\n> [PATCH] Really *do* nothing in while loop\n> \n> Signed-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>\n> \n> --- a/sha1_file.c\n> +++ b/sha1_file.c\n> @@ -335,7 +335,7 @@\n>  \tstream.next_in = hdr;\n>  \tstream.avail_in = hdrlen;\n>  \twhile (deflate(&stream, 0) == Z_OK)\n> -\t\t/* nothing */\n> +\t\t/* nothing */;\n>  \n>  \t/* Then the data itself.. */\n>  \tstream.next_in = buf;\n\nWell, the lack of semicolon is wrong really (and funny).\n\nBut is the whole while loop needed at all?  deflate()\nconsumes as much input as it can, producing as much output\nas it can.  So without the loop, and without updating the\nbuffer pointers ({next,avail}_{in,out}) it will do just\nfine without the loop, and will return something != Z_OK\non next iteration.  If this is to mean to flush output,\nit should be deflate(&stream, Z_FLUSH) or something.\n\n/mjt\n\nP.S.  What's git@vger.kernel.org for ?\n"},{"id":"2768","messageId":"20050508111840.GB12436@cip.informatik.uni-erlangen.de","threadId":"529","inReplyTo":"427DE086.40307@tls.msk.ru","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2005-05-08T11:18:40Z","receivedAt":"2005-05-08T11:18:40Z","isPatch":true,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"Hello,\n\n> >-\t\t/* nothing */\n> >+\t\t/* nothing */;\n\n> Well, the lack of semicolon is wrong really (and funny).\n\nyes, it is but harmless in this envrionment.\n\n> But is the whole while loop needed at all?  deflate()\n> consumes as much input as it can, producing as much output\n> as it can.  So without the loop, and without updating the\n> buffer pointers ({next,avail}_{in,out}) it will do just\n> fine without the loop, and will return something != Z_OK\n> on next iteration.  If this is to mean to flush output,\n> it should be deflate(&stream, Z_FLUSH) or something.\n\nI have no idea.\n\n> P.S.  What's git@vger.kernel.org for ?\n\nIt is the list which handles GIT related discussions. Frontend/backend\nand isn't kernel related.\n\n\tThomas\n"},{"id":"2769","messageId":"1115551204.3085.0.camel@kryten","threadId":"529","inReplyTo":"427DE086.40307@tls.msk.ru","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"James Purser","fromEmail":"purserj@ksit.dynalias.com","sentAt":"2005-05-08T11:20:04Z","receivedAt":"2005-05-08T11:20:04Z","isPatch":true,"sender":{"key":"purserj@ksit.dynalias.com","avatar":null},"body":"On Sun, 2005-05-08 at 19:48, Michael Tokarev wrote:\n> Thomas Glanzmann wrote:\n> > [PATCH] Really *do* nothing in while loop\n> > \n> > Signed-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>\n> > \n> > --- a/sha1_file.c\n> > +++ b/sha1_file.c\n> > @@ -335,7 +335,7 @@\n> >  \tstream.next_in = hdr;\n> >  \tstream.avail_in = hdrlen;\n> >  \twhile (deflate(&stream, 0) == Z_OK)\n> > -\t\t/* nothing */\n> > +\t\t/* nothing */;\n> >  \n> >  \t/* Then the data itself.. */\n> >  \tstream.next_in = buf;\n> \n> Well, the lack of semicolon is wrong really (and funny).\n> \n> But is the whole while loop needed at all?  deflate()\n> consumes as much input as it can, producing as much output\n> as it can.  So without the loop, and without updating the\n> buffer pointers ({next,avail}_{in,out}) it will do just\n> fine without the loop, and will return something != Z_OK\n> on next iteration.  If this is to mean to flush output,\n> it should be deflate(&stream, Z_FLUSH) or something.\n> \n> /mjt\n> \n> P.S.  What's git@vger.kernel.org for ?\nIts the mailing list for git development.\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n-- \nJames Purser\nhttp://ksit.dynalias.com\n\n"},{"id":"2770","messageId":"12e801c553c1$c454ea20$1225a8c0@kittycat","threadId":"529","inReplyTo":"1115551204.3085.0.camel@kryten","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"jdow","fromEmail":"jdow@earthlink.net","sentAt":"2005-05-08T11:33:32Z","receivedAt":"2005-05-08T11:33:32Z","isPatch":true,"sender":{"key":"jdow@earthlink.net","avatar":null},"body":"From: \"James Purser\" <purserj@ksit.dynalias.com>\n\n> On Sun, 2005-05-08 at 19:48, Michael Tokarev wrote:\n> > Thomas Glanzmann wrote:\n> > > [PATCH] Really *do* nothing in while loop\n> > > \n> > > Signed-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>\n> > > \n> > > --- a/sha1_file.c\n> > > +++ b/sha1_file.c\n> > > @@ -335,7 +335,7 @@\n> > >  stream.next_in = hdr;\n> > >  stream.avail_in = hdrlen;\n> > >  while (deflate(&stream, 0) == Z_OK)\n> > > - /* nothing */\n> > > + /* nothing */;\n> > >  \n> > >  /* Then the data itself.. */\n> > >  stream.next_in = buf;\n> > \n> > Well, the lack of semicolon is wrong really (and funny).\n\nYou guys REALLY do not see the changed semantics here? You are\nchanging:\n  while (deflate(&stream, 0) == Z_OK)\n      stream.next_in = buf;\n\ninto\n\n  while (deflate(&stream, 0) == Z_OK)\n    ;\n  /* Then the data itself.. */\n  stream.next_in = buf;\n\nI suspect the results of that tiny bit of code would be slightly\ndifferent, especially if \"stream.next_in\" is volatile, \"buf\"\nis volatile, or if the assignment to next_in has an effect on\nthe \"deflate\" operation.\n\n{^_^}\n\n\n\n"},{"id":"2771","messageId":"427DFAB8.5050000@tls.msk.ru","threadId":"529","inReplyTo":"12e801c553c1$c454ea20$1225a8c0@kittycat","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Michael Tokarev","fromEmail":"mjt@tls.msk.ru","sentAt":"2005-05-08T11:40:40Z","receivedAt":"2005-05-08T11:40:40Z","isPatch":true,"sender":{"key":"mjt@tls.msk.ru","avatar":null},"body":"jdow wrote:\n> From: \"James Purser\" <purserj@ksit.dynalias.com>\n> \n   while (deflate(&stream, 0) == Z_OK)\n-  /* nothing */\n+  /* nothing */;\n  stream.next_in = buf;\n> \n> You guys REALLY do not see the changed semantics here? You are\n> changing:\n>   while (deflate(&stream, 0) == Z_OK)\n>       stream.next_in = buf;\n> \n> into\n> \n>   while (deflate(&stream, 0) == Z_OK)\n>     ;\n>   /* Then the data itself.. */\n>   stream.next_in = buf;\n> \n> I suspect the results of that tiny bit of code would be slightly\n> different, especially if \"stream.next_in\" is volatile, \"buf\"\n> is volatile, or if the assignment to next_in has an effect on\n> the \"deflate\" operation.\n\nAs I already said, deflate() in this case does only ONE iteration.\nstream.avail_in is NOT changed in the loop (except of the deflate()\nitself, where it will be set to 0 - provided out buffer have enouth\nroom).  So the whole while loop does only ONE iteration, returning\nZ_NEED_DATA or something the next one.  So no, the semantics here\n(actual semantics) does NOT change.\n\n/mjt\n"},{"id":"2824","messageId":"7vy8ap4e8l.fsf@assigned-by-dhcp.cox.net","threadId":"529","inReplyTo":"427DFAB8.5050000@tls.msk.ru","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-08T21:08:58Z","receivedAt":"2005-05-08T21:08:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"MT\" == Michael Tokarev <mjt@tls.msk.ru> writes:\n\nMT> As I already said, deflate() in this case does only ONE iteration.\nMT> stream.avail_in is NOT changed in the loop (except of the deflate()\nMT> itself, where it will be set to 0 - provided out buffer have enouth\nMT> room)....\n\nJust a stupid question, but what happens when we do not have\nenough room in the buffer?\n\n"},{"id":"2827","messageId":"Pine.LNX.4.21.0505081713070.30848-100000@iabervon.org","threadId":"529","inReplyTo":"7vy8ap4e8l.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-05-08T21:16:21Z","receivedAt":"2005-05-08T21:16:21Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 8 May 2005, Junio C Hamano wrote:\n\n> >>>>> \"MT\" == Michael Tokarev <mjt@tls.msk.ru> writes:\n> \n> MT> As I already said, deflate() in this case does only ONE iteration.\n> MT> stream.avail_in is NOT changed in the loop (except of the deflate()\n> MT> itself, where it will be set to 0 - provided out buffer have enouth\n> MT> room)....\n> \n> Just a stupid question, but what happens when we do not have\n> enough room in the buffer?\n\nWe must have enough room; we sized the buffer with deflateBound to fit the\nworst case.\n\n\t-Daniel\n*This .sig left intentionally blank*\n\n\n"},{"id":"2832","messageId":"7vu0ld4d0k.fsf@assigned-by-dhcp.cox.net","threadId":"529","inReplyTo":"Pine.LNX.4.21.0505081713070.30848-100000@iabervon.org","subject":"Re: [PATCH] Really *do* nothing in while loop","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-08T21:35:23Z","receivedAt":"2005-05-08T21:35:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"DB\" == Daniel Barkalow <barkalow@iabervon.org> writes:\n\nDB> On Sun, 8 May 2005, Junio C Hamano wrote:\n>> \nMT> As I already said, deflate() in this case does only ONE iteration.\nMT> stream.avail_in is NOT changed in the loop (except of the deflate()\nMT> itself, where it will be set to 0 - provided out buffer have enouth\nMT> room)....\n>> \n>> Just a stupid question, but what happens when we do not have\n>> enough room in the buffer?\n\nDB> We must have enough room; we sized the buffer with deflateBound to fit the\nDB> worst case.\n\nThanks for the explanation.  Then do we still need to express it\nas a while loop?\n\n\n"}]}