{"thread":{"id":"19812","subject":"[PATCH] Cast things properly to handle >2G files.","startedAt":"2009-06-14T20:03:03Z","lastAt":"2009-06-18T21:48:29Z","messageCount":23,"participants":["Alfred M. Szmidt","Johannes Schindelin","Nicolas Pitre","Junio C Hamano","Linus Torvalds","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116290","messageId":"E1MFvux-0001ix-I7@fencepost.gnu.org","threadId":"19812","inReplyTo":null,"subject":"[PATCH] Cast things properly to handle >2G files.","fromName":"Alfred M. Szmidt","fromEmail":"ams@gnu.org","sentAt":"2009-06-14T20:03:03Z","receivedAt":"2009-06-14T20:03:03Z","isPatch":true,"sender":{"key":"ams@gnu.org","avatar":"https://gravatar.com/avatar/46825633bc1d168c418bbf90c7859b9f83888b45d7cc546a8544df495858df83?d=mp&s=160"},"body":"This small patch fixes things so that repack, fsck, and other things\nwork on >2GiB files.  There are still some other problems (cloning\nover ssh being one), but this makes it atleast possible to handle such\nfiles.\n\n(not subscribed, please CC)\n\n---\n delta.h       |    2 +-\n patch-delta.c |    2 +-\n sha1_file.c   |    2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/delta.h b/delta.h\nindex 40ccf5a..b3acc72 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -95,7 +95,7 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\n-\t\tsize |= (cmd & ~0x80) << i;\n+\t\tsize |= (cmd & ~0x80UL) << i;\n \t\ti += 7;\n \t} while (cmd & 0x80 && data < top);\n \t*datap = data;\ndiff --git a/patch-delta.c b/patch-delta.c\nindex ed9db81..a9ad2bc 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -44,7 +44,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,\n \t\t\tif (cmd & 0x01) cp_off = *data++;\n \t\t\tif (cmd & 0x02) cp_off |= (*data++ << 8);\n \t\t\tif (cmd & 0x04) cp_off |= (*data++ << 16);\n-\t\t\tif (cmd & 0x08) cp_off |= (*data++ << 24);\n+\t\t\tif (cmd & 0x08) cp_off |= ((unsigned long) *data++ << 24);\n \t\t\tif (cmd & 0x10) cp_size = *data++;\n \t\t\tif (cmd & 0x20) cp_size |= (*data++ << 8);\n \t\t\tif (cmd & 0x40) cp_size |= (*data++ << 16);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e73cd4f..4566ea1 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1176,7 +1176,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \t\t\treturn 0;\n \t\t}\n \t\tc = buf[used++];\n-\t\tsize += (c & 0x7f) << shift;\n+\t\tsize += (c & 0x7fUL) << shift;\n \t\tshift += 7;\n \t}\n \t*sizep = size;\n-- \n1.6.3.2.225.gb8364.dirty\n"},{"id":"116291","messageId":"alpine.DEB.1.00.0906142215560.26154@pacific.mpi-cbg.de","threadId":"19812","inReplyTo":"E1MFvux-0001ix-I7@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-14T20:17:15Z","receivedAt":"2009-06-14T20:17:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nDisclaimer: if you are offended by constructive criticism, or likely to\nanswer with insults to the comments I offer, please stop reading this mail\nnow (and please do not answer my mail, either). :-)\n\nStill with me?  Good.  Nice to meet you.\n\nJust for the record: responding to a patch is my strongest way of saying\nthat I appreciate your work.\n\nOn Sun, 14 Jun 2009, Alfred M. Szmidt wrote:\n\n> This small patch fixes things so that repack, fsck, and other things\n> work on >2GiB files.  There are still some other problems (cloning\n> over ssh being one), but this makes it atleast possible to handle such\n> files.\n> \n> (not subscribed, please CC)\n\nThis is almost perfect, but please add a Signed-off-by: line.\n\nOh, and maybe add a test like t/t5705-clone-2gb.sh?\n\nCiao,\nDscho\n"},{"id":"116304","messageId":"alpine.LFD.2.00.0906142239120.16467@xanadu.home","threadId":"19812","inReplyTo":"alpine.DEB.1.00.0906142215560.26154@pacific.mpi-cbg.de","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-06-15T02:43:46Z","receivedAt":"2009-06-15T02:43:46Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Sun, 14 Jun 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> Disclaimer: if you are offended by constructive criticism, or likely to\n> answer with insults to the comments I offer, please stop reading this mail\n> now (and please do not answer my mail, either). :-)\n> \n> Still with me?  Good.  Nice to meet you.\n> \n> Just for the record: responding to a patch is my strongest way of saying\n> that I appreciate your work.\n> \n> On Sun, 14 Jun 2009, Alfred M. Szmidt wrote:\n> \n> > This small patch fixes things so that repack, fsck, and other things\n> > work on >2GiB files.  There are still some other problems (cloning\n> > over ssh being one), but this makes it atleast possible to handle such\n> > files.\n> > \n> > (not subscribed, please CC)\n> \n> This is almost perfect, but please add a Signed-off-by: line.\n> \n> Oh, and maybe add a test like t/t5705-clone-2gb.sh?\n\nCreating test for files >= 2GB is kinda hard.  It'll be really slow and \ntake a lot of disk space, and I doubt people will be happy about that.\n\nBeen there.  That's the only reason why I created the --index-version \nargument to pack-objects: to fake behavior for huge files by the test \nsuite.\n\n\nNicolas\n"},{"id":"116308","messageId":"E1MG32S-0004C6-8A@fencepost.gnu.org","threadId":"19812","inReplyTo":"alpine.DEB.1.00.0906142215560.26154@pacific.mpi-cbg.de","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Alfred M. Szmidt","fromEmail":"ams@gnu.org","sentAt":"2009-06-15T03:39:16Z","receivedAt":"2009-06-15T03:39:16Z","isPatch":true,"sender":{"key":"ams@gnu.org","avatar":"https://gravatar.com/avatar/46825633bc1d168c418bbf90c7859b9f83888b45d7cc546a8544df495858df83?d=mp&s=160"},"body":"   > This small patch fixes things so that repack, fsck, and other\n   > things work on >2GiB files.  There are still some other problems\n   > (cloning over ssh being one), but this makes it atleast possible\n   > to handle such files.\n\n   This is almost perfect, but please add a Signed-off-by: line.\n\nI cannot agree to the D-C-O in good faith, since it speaks of open\nsource licenses, a group of licenses that include non-free software\nlicenses, something which I cannot support.\n\n   Oh, and maybe add a test like t/t5705-clone-2gb.sh?\n\nThank you, that is a very good idea.\n\n(still not subscribed, please CC)\n"},{"id":"116309","messageId":"7vmy8ap2cq.fsf@alter.siamese.dyndns.org","threadId":"19812","inReplyTo":"E1MG32S-0004C6-8A@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-15T04:06:45Z","receivedAt":"2009-06-15T04:06:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alfred M. Szmidt\" <ams@gnu.org> writes:\n\n> I cannot agree to the D-C-O in good faith, since it speaks of open\n> source licenses, a group of licenses that include non-free software\n> licenses, something which I cannot support.\n\nDCO is not something you \"agree to\".\n\nAre you the original author of the patch, and have the right to submit it\nunder the license \"indicated in the file\"?\n\nThe overall license of git is GPLv2, and that is what applies to unless\nthere is an explicit license term indicated in the file otherwise. We do\nhave some code under different licenses in some parts of the system, but\nthe files that you are touching are all GPLv2.\n\nCan you certify that your patch is yours and you have rights to make it\npart of git under the same terms as the original?  Or can you not?  There\nis nothing for you to \"agree to\"; just a simple \"yes or no\", and I hope\nthe answer is yes in this case, judging from your gnu.org address.\n\n>    Oh, and maybe add a test like t/t5705-clone-2gb.sh?\n>\n> Thank you, that is a very good idea.\n\nNah, one blob that is over 2gb, deltified against something else?  That's\na bit too much for a test script.\n"},{"id":"116311","messageId":"alpine.LFD.2.01.0906142118250.3305@localhost.localdomain","threadId":"19812","inReplyTo":"E1MG32S-0004C6-8A@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-15T04:25:34Z","receivedAt":"2009-06-15T04:25:34Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 14 Jun 2009, Alfred M. Szmidt wrote:\n> \n> I cannot agree to the D-C-O in good faith, since it speaks of open\n> source licenses, a group of licenses that include non-free software\n> licenses, something which I cannot support.\n\nIf you can't sign off on it, then Junio shouldn't take it, since you're \nbasically saying that you cannot say that you own the copyrights or cannot \nlicense it under the appropriate copyright.\n\nYes, it speaks of \"open source licenses\", but it says: \"under the open \nsource license indicated in the file\", and \"appropriate open source\nlicense\".\n\nFor git, that's GPLv2 (or GPLv2-compatible, ie something like the \nsimplified BSD license that can just be converted to GPLv2).\n\nThe DCO is phrased that way so that other projects that use things like \nthe BSD or Apache license can still use the DCO as-is.\n\nSide note: for somebody with a \"gnu.org\" address, you're showing some \nreally bad taste. Do you know that the FSF ends up asking for a hell of a \nlot of paperwork and other crazy things to take peoples submissions. And \nthey actually want the copyrights signed over, so that they can change it \nto _any_ license.\n\nThe DCO, in contrast, is a paragon of simplicity and clarity, and doesn't \nask you to sign away any rights.\n\n\t\t\tLinus\n"},{"id":"116323","messageId":"alpine.DEB.1.00.0906151043180.4245@intel-tinevez-2-302","threadId":"19812","inReplyTo":"7vmy8ap2cq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-15T08:45:37Z","receivedAt":"2009-06-15T08:45:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 14 Jun 2009, Junio C Hamano wrote:\n\n> \"Alfred M. Szmidt\" <ams@gnu.org> writes:\n> \n> >    Oh, and maybe add a test like t/t5705-clone-2gb.sh?\n> >\n> > Thank you, that is a very good idea.\n> \n> Nah, one blob that is over 2gb, deltified against something else?  \n> That's a bit too much for a test script.\n\nWhy not?  It's not a difficult thing to come up with such a test.  And \njust like t5705, it can be hidden behind an \"EXPENSIVE_TEST=YesPlease\" \nenvironment variable.  Maybe I should have spelt that out loud instead of \nrelying on interested parties to know t5705.\n\nAnd just like t5705 it should help people to verify that the patch solves \nthe problems indeed.\n\nCiao,\nDscho\n"},{"id":"116509","messageId":"E1MH3bD-0004fq-07@fencepost.gnu.org","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906142118250.3305@localhost.localdomain","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Alfred M. Szmidt","fromEmail":"ams@gnu.org","sentAt":"2009-06-17T22:27:19Z","receivedAt":"2009-06-17T22:27:19Z","isPatch":true,"sender":{"key":"ams@gnu.org","avatar":"https://gravatar.com/avatar/46825633bc1d168c418bbf90c7859b9f83888b45d7cc546a8544df495858df83?d=mp&s=160"},"body":"   Side note: for somebody with a \"gnu.org\" address, you're showing\n   some really bad taste. Do you know that the FSF ends up asking for\n   a hell of a lot of paperwork and other crazy things to take peoples\n   submissions. And they actually want the copyrights signed over, so\n   that they can change it to _any_ license.\n\n   The DCO, in contrast, is a paragon of simplicity and clarity, and\n   doesn't ask you to sign away any rights.\n\nYou are misinformed.  The copyright assignments from the FSF explictly\nstate that the code will always be free software, and they grant back\nall rights to the code you assigned to them.\n"},{"id":"116510","messageId":"E1MH3bD-0004g2-97@fencepost.gnu.org","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906142118250.3305@localhost.localdomain","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Alfred M. Szmidt","fromEmail":"ams@gnu.org","sentAt":"2009-06-17T22:27:19Z","receivedAt":"2009-06-17T22:27:19Z","isPatch":true,"sender":{"key":"ams@gnu.org","avatar":"https://gravatar.com/avatar/46825633bc1d168c418bbf90c7859b9f83888b45d7cc546a8544df495858df83?d=mp&s=160"},"body":"   > I cannot agree to the D-C-O in good faith, since it speaks of\n   > open source licenses, a group of licenses that include non-free\n   > software licenses, something which I cannot support.\n\n   If you can't sign off on it, then Junio shouldn't take it, since\n   you're basically saying that you cannot say that you own the\n   copyrights or cannot license it under the appropriate copyright.\n\nThat is not what I am saying.  In either case, I already explained why\nI cannot agree to the DCO above.  And you are right, Junio shouldn't\napply the patch if it goes against commit policies.\n\n   Yes, it speaks of \"open source licenses\", but it says: \"under the\n   open source license indicated in the file\", and \"appropriate open\n   source license\".\n\nThat is a good point, almost none of the files in git specify the\nlicense so it is impossible to know what one is actually agreeing too.\n\nI would suggest the following update to the DCO, it makes it more\ngeneral both to free software hackers, and open source hackers alike.\n\n  Developer's Certificate of Origin 1.2-draft\n\n  By making a contribution to this project, I certify that:\n\n  (a) The contribution was created in whole or in part by me and I\n      have the right to submit it under the license indicated in the\n      file; or\n\n  (b) The contribution is based upon previous work that, to the best\n      of my knowledge, is covered under an compatible license and I\n      have the right under that license to submit that work with\n      modifications, whether created in whole or in part by me, under\n      the same license (unless I am permitted to submit under a\n      different license), as indicated in the file; or\n\n  (c) The contribution was provided directly to me by some other\n      person who certified (a), (b) or (c) and I have not modified it.\n\n  (d) I understand and agree that this project and the contribution\n      are public and that a record of the contribution (including all\n      personal information I submit with it, including my sign-off) is\n      maintained indefinitely and may be redistributed consistent with\n      this project or the license(s) involved.\n"},{"id":"116511","messageId":"alpine.LFD.2.01.0906171543120.16802@localhost.localdomain","threadId":"19812","inReplyTo":"E1MH3bD-0004g2-97@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-17T22:45:16Z","receivedAt":"2009-06-17T22:45:16Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 Jun 2009, Alfred M. Szmidt wrote:\n> \n> I would suggest the following update to the DCO, it makes it more\n> general both to free software hackers, and open source hackers alike.\n\nAnd I would suggest that Junio just not take patches from people who \naren't able to read the existing DCO. It's not worth the pain. \n\n\t\tLinus\n"},{"id":"116512","messageId":"alpine.LFD.2.01.0906171543510.16802@localhost.localdomain","threadId":"19812","inReplyTo":"E1MH3bD-0004fq-07@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-17T22:48:44Z","receivedAt":"2009-06-17T22:48:44Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 Jun 2009, Alfred M. Szmidt wrote:\n>    The DCO, in contrast, is a paragon of simplicity and clarity, and\n>    doesn't ask you to sign away any rights.\n> \n> You are misinformed.  The copyright assignments from the FSF explictly\n> state that the code will always be free software, and they grant back\n> all rights to the code you assigned to them.\n\nBlah. They define the term \"free software\" too, so that doesn't make any \ndifference. They can relicense it any crazy way they want, as shown by the \nwhole annoying GPLv3 idiocy. It doesn't matter one whit whether you agree \nwith them or not.\n\nAnd isn't it \"nice\" of them to not require exclusive ownership? Gag. And \nwhat a bunch of hypocritical people they are too - because they'll happily \ntake code from other people without any copyright assignment what-so-ever \nwhen they feel like it (case in point: Hurd took drivers and filesystems \nfrom Linux, and I can pretty much guarantee that they didn't have \ncopyright assignments for any of it - but hey, rules are rules only when \nthey apply to _other_ people, right?)\n\nAnd you didn't face the actual issue: the papers the FSF makes you sign \nare _way_ less obvious than the DCO is.\n\n\t\tLinus\n"},{"id":"116513","messageId":"alpine.LFD.2.01.0906171550450.16802@localhost.localdomain","threadId":"19812","inReplyTo":"E1MH3bD-0004g2-97@fencepost.gnu.org","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-17T22:51:10Z","receivedAt":"2009-06-17T22:51:10Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 17 Jun 2009, Alfred M. Szmidt wrote:\n> \n> That is a good point, almost none of the files in git specify the\n> license so it is impossible to know what one is actually agreeing too.\n\nRight. Because that \"COPYING\" file is so hard to find.\n\nYou're making excuses. Just admit it.\n\n\t\tLinus\n"},{"id":"116514","messageId":"7v7hzae9iz.fsf@alter.siamese.dyndns.org","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906171543120.16802@localhost.localdomain","subject":"Re: [PATCH] Cast things properly to handle >2G files.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-17T23:16:20Z","receivedAt":"2009-06-17T23:16:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Wed, 17 Jun 2009, Alfred M. Szmidt wrote:\n>> \n>> I would suggest the following update to the DCO, it makes it more\n>> general both to free software hackers, and open source hackers alike.\n>\n> And I would suggest that Junio just not take patches from people who \n> aren't able to read the existing DCO. It's not worth the pain. \n>\n> \t\tLinus\n\nThanks for trying to reduce my load.  Very much appreciated.\n\nEven though I am _not_ a nice person, I _am_ a practical one.  Before\nstopping to pay attention to this thread, I'll quote from my response once\nmore to ask a simple yes-or-no questions to Alfred.\n\n  Are you the original author of the patch, and have the right to submit\n  it under the license \"indicated in the file\"?\n\n  The overall license of git is GPLv2, and that is what applies to unless\n  there is an explicit license term indicated in the file otherwise. We do\n  have some code under different licenses in some parts of the system, but\n  the files that you are touching are all GPLv2.\n\n  Can you certify that your patch is yours and you have rights to make it\n  part of git under the same terms as the original?  Or can you not?\n\nSo Alfred, \"yes\"?  or \"no\"?  If \"yes\", you can send a sign-off.\n\nOf course you can choose not to even if the answer is \"yes\", but then we\ncan choose to ignore your patch, too; and in fact we probably have to.\n"},{"id":"116516","messageId":"alpine.LFD.2.01.0906171654310.16802@localhost.localdomain","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906171543120.16802@localhost.localdomain","subject":"Fix big left-shifts of unsigned char","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T00:22:27Z","receivedAt":"2009-06-18T00:22:27Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nShifting 'unsigned char' or 'unsigned short' left can result in sign \nextension errors, since the C integer promotion rules means that the \nunsigned char/short will get implicitly promoted to a signed 'int' due to \nthe shift (or due to other operations).\n\nThis normally doesn't matter, but if you shift things up sufficiently, it \nwill now set the sign bit in 'int', and a subsequent cast to a bigger type \n(eg 'long' or 'unsigned long') will now sign-extend the value despite the \noriginal expression being unsigned.\n\nOne example of this would be something like\n\n\tunsigned long size;\n\tunsigned char c;\n\n\tsize += c << 24;\n\nwhere despite all the variables being unsigned, 'c << 24' ends up being a \nsigned entity, and will get sign-extended when then doing the addition in \nan 'unsigned long' type.\n\nSince git uses 'unsigned char' pointers extensively, we actually have this \nbug in a couple of places. \n\nI may have missed some, but this is the result of looking at\n\n\tgit grep '[^0-9 \t][ \t]*<<[ \t][a-z]' -- '*.c' '*.h'\n\tgit grep '<<[   ]*24'\n\nwhich catches at least the common byte cases (shifting variables by a \nvariable amount, and shifting by 24 bits).\n\nI also grepped for just 'unsigned char' variables in general, and \nconverted the ones that most obviously ended up getting implicitly cast \nimmediately anyway (eg hash_name(), encode_85()).\n\nIn addition to just avoiding 'unsigned char', this patch also tries to use \na common idiom for the delta header size thing. We had three different \nvariations on it: \"& 0x7fUL\" in one place (getting the sign extension \nright), and \"& ~0x80\" and \"& 0x7f\" in two other places (not getting it \nright). Apart from making them all just avoid using \"unsigned char\" at \nall, I also unified them to then use a simple \"& 0x7f\".\n\nI considered making a sparse extension which warns about doing implicit \ncasts from unsigned types to signed types, but it gets rather complex very \nquickly, so this is just a hack. \n\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n---\n\nThis is _not_ tested in any way. And I got bored with getting rid of \n'unsigned char' variables, so I by no means did all of them, just the \nfirst few that caugth my grepping eye.\n\nOn Wed, 17 Jun 2009, Linus Torvalds wrote:\n> \n> And I would suggest that Junio just not take patches from people who \n> aren't able to read the existing DCO. It's not worth the pain. \n> \n> \t\tLinus\n> \n\n attr.c                   |    3 +--\n base85.c                 |    2 +-\n builtin-pack-objects.c   |    3 +--\n builtin-unpack-objects.c |    4 ++--\n delta.h                  |    5 ++---\n index-pack.c             |    6 +++---\n patch-delta.c            |    2 +-\n sha1_file.c              |    3 +--\n 8 files changed, 12 insertions(+), 16 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 98eb636..f8f6faa 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -35,8 +35,7 @@ static struct git_attr *(git_attr_hash[HASHSIZE]);\n \n static unsigned hash_name(const char *name, int namelen)\n {\n-\tunsigned val = 0;\n-\tunsigned char c;\n+\tunsigned val = 0, c;\n \n \twhile (namelen--) {\n \t\tc = *name++;\ndiff --git a/base85.c b/base85.c\nindex b88270f..b417a15 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -91,7 +91,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)\n \t\tunsigned acc = 0;\n \t\tint cnt;\n \t\tfor (cnt = 24; cnt >= 0; cnt -= 8) {\n-\t\t\tint ch = *data++;\n+\t\t\tunsigned ch = *data++;\n \t\t\tacc |= ch << cnt;\n \t\t\tif (--bytes == 0)\n \t\t\t\tbreak;\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 9742b45..941cc2d 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -653,8 +653,7 @@ static void rehash_objects(void)\n \n static unsigned name_hash(const char *name)\n {\n-\tunsigned char c;\n-\tunsigned hash = 0;\n+\tunsigned c, hash = 0;\n \n \tif (!name)\n \t\treturn 0;\ndiff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c\nindex 9a77323..8e831be 100644\n--- a/builtin-unpack-objects.c\n+++ b/builtin-unpack-objects.c\n@@ -422,8 +422,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n-\tunsigned char *pack, c;\n-\tunsigned long size;\n+\tunsigned char *pack;\n+\tunsigned long size, c;\n \tenum object_type type;\n \n \tobj_list[nr].offset = consumed_bytes;\ndiff --git a/delta.h b/delta.h\nindex 40ccf5a..b9d333d 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -90,12 +90,11 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n \t\t\t\t\t       const unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned char cmd;\n-\tunsigned long size = 0;\n+\tunsigned long cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\n-\t\tsize |= (cmd & ~0x80) << i;\n+\t\tsize |= (cmd & 0x7f) << i;\n \t\ti += 7;\n \t} while (cmd & 0x80 && data < top);\n \t*datap = data;\ndiff --git a/index-pack.c b/index-pack.c\nindex 6e93ee6..0c92baf 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -293,8 +293,8 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)\n \n static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_base)\n {\n-\tunsigned char *p, c;\n-\tunsigned long size;\n+\tunsigned char *p;\n+\tunsigned long size, c;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -312,7 +312,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_\n \t\tp = fill(1);\n \t\tc = *p;\n \t\tuse(1);\n-\t\tsize += (c & 0x7fUL) << shift;\n+\t\tsize += (c & 0x7f) << shift;\n \t\tshift += 7;\n \t}\n \tobj->size = size;\ndiff --git a/patch-delta.c b/patch-delta.c\nindex ed9db81..ef748ce 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -44,7 +44,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,\n \t\t\tif (cmd & 0x01) cp_off = *data++;\n \t\t\tif (cmd & 0x02) cp_off |= (*data++ << 8);\n \t\t\tif (cmd & 0x04) cp_off |= (*data++ << 16);\n-\t\t\tif (cmd & 0x08) cp_off |= (*data++ << 24);\n+\t\t\tif (cmd & 0x08) cp_off |= ((unsigned) *data++ << 24);\n \t\t\tif (cmd & 0x10) cp_size = *data++;\n \t\t\tif (cmd & 0x20) cp_size |= (*data++ << 8);\n \t\t\tif (cmd & 0x40) cp_size |= (*data++ << 16);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e73cd4f..8f5fe62 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1162,8 +1162,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n {\n \tunsigned shift;\n-\tunsigned char c;\n-\tunsigned long size;\n+\tunsigned long size, c;\n \tunsigned long used = 0;\n \n \tc = buf[used++];\n"},{"id":"116536","messageId":"alpine.DEB.1.00.0906181012050.4848@intel-tinevez-2-302","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906171654310.16802@localhost.localdomain","subject":"Re: Fix big left-shifts of unsigned char","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-18T08:12:37Z","receivedAt":"2009-06-18T08:12:37Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 17 Jun 2009, Linus Torvalds wrote:\n\n> This is _not_ tested in any way. And I got bored with getting rid of \n> 'unsigned char' variables, so I by no means did all of them, just the \n> first few that caugth my grepping eye.\n\nI wonder if there is a mode of 'sparse' which could spot these buggers.\n\nCiao,\nDscho\n"},{"id":"116540","messageId":"7vbpomymsf.fsf@alter.siamese.dyndns.org","threadId":"19812","inReplyTo":"alpine.DEB.1.00.0906181012050.4848@intel-tinevez-2-302","subject":"Re: Fix big left-shifts of unsigned char","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-18T08:21:52Z","receivedAt":"2009-06-18T08:21:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 17 Jun 2009, Linus Torvalds wrote:\n>\n>> This is _not_ tested in any way. And I got bored with getting rid of \n>> 'unsigned char' variables, so I by no means did all of them, just the \n>> first few that caugth my grepping eye.\n>\n> I wonder if there is a mode of 'sparse' which could spot these buggers.\n\nThat's a very good meta question ;-)\n"},{"id":"116581","messageId":"alpine.LFD.2.01.0906180856420.16802@localhost.localdomain","threadId":"19812","inReplyTo":"alpine.DEB.1.00.0906181012050.4848@intel-tinevez-2-302","subject":"Re: Fix big left-shifts of unsigned char","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T16:08:35Z","receivedAt":"2009-06-18T16:08:35Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 18 Jun 2009, Johannes Schindelin wrote:\n> \n> I wonder if there is a mode of 'sparse' which could spot these buggers.\n\nHmm. A very quick hack gets me (this is _after_ my patch):\n\n\tdiffcore-delta.c:53:24: warning: Signed left-shift\n\tdiffcore-delta.c:58:21: warning: Signed left-shift\n\tdiffcore-delta.c:88:21: warning: Signed left-shift\n\nwhich are all of the type \"<< alloc_log\", and not very interesting.\n\n\tread-cache.c:1155:17: warning: Signed left-shift\n\nThis one is \"real\", and I noticed it in my earlier greps, but we don't \ncare (it's the CACHE_EXT_TREE/CACHE_EXT() matching, and it's all done in \n\"int\", and the only case we care about is a non-signed case anyway)\n\n\timap-send.c:785:52: warning: Signed left-shift\n\timap-send.c:1190:35: warning: Signed left-shift\n\nThese are both \"real\", but we're only working on \"unsigned\" so we don't \nreally care.\n\n\tbuiltin-rev-list.c:201:21: warning: Signed left-shift\n\nthis is exp2i(), and it returns 'int', and wouldn't work for big left \nshifts anyway.\n\nAnd just to see that my sparse logic actually worked, _without_ the patch \nI sent to fix left-shifts, I got these:\n\n\tbase85.c:95:38: warning: Signed left-shift\t\t(fixed)\n\tdiffcore-delta.c:53:24: warning: Signed left-shift\n\tdiffcore-delta.c:58:21: warning: Signed left-shift\n\tdiffcore-delta.c:88:21: warning: Signed left-shift\n\tdelta.h:98:42: warning: Signed left-shift\t\t(fixed)\n\tdelta.h:98:42: warning: Signed left-shift\t\t(dup - inline)\n\tpatch-delta.c:47:63: warning: Signed left-shift\t\t(fixed)\n\tread-cache.c:1155:17: warning: Signed left-shift\n\tsha1_file.c:1179:39: warning: Signed left-shift\t\t(fixed)\n\tdelta.h:98:42: warning: Signed left-shift\t\t(dup - inline)\n\tdelta.h:98:42: warning: Signed left-shift\t\t(dup - inline)\n\timap-send.c:785:52: warning: Signed left-shift\n\timap-send.c:1190:35: warning: Signed left-shift\n\tbuiltin-rev-list.c:201:21: warning: Signed left-shift\n\tbuiltin-unpack-objects.c:441:39: warning: Signed left-shift (fixed)\n\njust to verify that my sparse checker actually found the ones the patch \nmodified.\n\n\t\t\tLinus\n"},{"id":"116584","messageId":"alpine.DEB.1.00.0906181845020.4297@intel-tinevez-2-302","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906180856420.16802@localhost.localdomain","subject":"Re: Fix big left-shifts of unsigned char","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-18T16:45:43Z","receivedAt":"2009-06-18T16:45:43Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 18 Jun 2009, Linus Torvalds wrote:\n\n> On Thu, 18 Jun 2009, Johannes Schindelin wrote:\n> \n> > I wonder if there is a mode of 'sparse' which could spot these \n> > buggers.\n> \n> Hmm. A very quick hack gets me (this is _after_ my patch):\n>\n> [snip thorough analysis]\n\nNice.\n\nThe quick hack is not going to be part of sparse.git, I take it?\n\nCiao,\nDscho\n"},{"id":"116586","messageId":"alpine.LFD.2.01.0906181013390.16802@localhost.localdomain","threadId":"19812","inReplyTo":"alpine.DEB.1.00.0906181845020.4297@intel-tinevez-2-302","subject":"Re: Fix big left-shifts of unsigned char","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T17:15:17Z","receivedAt":"2009-06-18T17:15:17Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 18 Jun 2009, Johannes Schindelin wrote:\n> \n> The quick hack is not going to be part of sparse.git, I take it?\n\nNot clear yet. I sent a couple of patches to the sparse list already to \nmake things go better in general with running sparse on git. I can now do\n\n\tmake \"CC=cgcc -m64\"\n\non my git tree, and get reasonable warnings. I'll play around with it \nthat whole left-shift thing a bit more, but before I do that I'll post a \npatch for all the _other_ things sparse found in git.\n\n\t\tLinus\n"},{"id":"116589","messageId":"alpine.LFD.2.01.0906181021520.16802@localhost.localdomain","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906181013390.16802@localhost.localdomain","subject":"Fix various sparse warnings in the git source code","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T17:28:43Z","receivedAt":"2009-06-18T17:28:43Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThere are a few remaining ones, but this fixes the trivial ones. It boils \ndown to two main issues that sparse complains about:\n\n - warning: Using plain integer as NULL pointer\n\n   Sparse doesn't like you using '0' instead of 'NULL'. For various good \n   reasons, not the least of which is just the visual confusion. A NULL \n   pointer is not an integer, and that whole \"0 works as NULL\" is a \n   historical accident and not very pretty.\n\n   A few of these remain: zlib is a total mess, and Z_NULL is just a 0. \n   I didn't touch those.\n\n - warning: symbol 'xyz' was not declared. Should it be static?\n\n   Sparse wwants to see declarations for any functions you export. A lack \n   fo a declaration tends to mean that you should either add one, or you \n   should mark the function 'static' to show that it's in file scope. \n\n   A few of these remain: I only did the ones that should obviously just \n   be made static.\n\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n---\n\nWith this, and a few sparse fixes, git is _mostly_ sparse-clean.\n\nOn Thu, 18 Jun 2009, Linus Torvalds wrote:\n> \n> \n> On Thu, 18 Jun 2009, Johannes Schindelin wrote:\n> > \n> > The quick hack is not going to be part of sparse.git, I take it?\n> \n> Not clear yet. I sent a couple of patches to the sparse list already to \n> make things go better in general with running sparse on git. I can now do\n> \n> \tmake \"CC=cgcc -m64\"\n> \n> on my git tree, and get reasonable warnings. I'll play around with it \n> that whole left-shift thing a bit more, but before I do that I'll post a \n> patch for all the _other_ things sparse found in git.\n> \n> \t\tLinus\n> \n\n bisect.c                 |    4 ++--\n builtin-add.c            |    2 +-\n builtin-apply.c          |    2 +-\n builtin-clone.c          |    2 +-\n builtin-fsck.c           |    4 ++--\n builtin-help.c           |    2 +-\n builtin-log.c            |    4 ++--\n builtin-merge.c          |    4 ++--\n builtin-remote.c         |   16 ++++++++--------\n builtin-unpack-objects.c |    6 +++---\n connect.c                |    2 +-\n daemon.c                 |    2 +-\n imap-send.c              |    2 +-\n index-pack.c             |    2 +-\n mailmap.c                |    6 +++---\n merge-recursive.c        |    2 +-\n parse-options.c          |    2 +-\n quote.c                  |    4 ++--\n remote.c                 |    6 +++---\n test-parse-options.c     |    4 ++--\n 20 files changed, 39 insertions(+), 39 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 6fdff05..dbeb287 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -454,7 +454,7 @@ static int read_bisect_refs(void)\n \treturn for_each_ref_in(\"refs/bisect/\", register_ref, NULL);\n }\n \n-void read_bisect_paths(struct argv_array *array)\n+static void read_bisect_paths(struct argv_array *array)\n {\n \tstruct strbuf str = STRBUF_INIT;\n \tconst char *filename = git_path(\"BISECT_NAMES\");\n@@ -780,7 +780,7 @@ static void handle_bad_merge_base(void)\n \texit(1);\n }\n \n-void handle_skipped_merge_base(const unsigned char *mb)\n+static void handle_skipped_merge_base(const unsigned char *mb)\n {\n \tchar *mb_hex = sha1_to_hex(mb);\n \tchar *bad_hex = sha1_to_hex(current_bad_sha1);\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 566c313..ad8e562 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -160,7 +160,7 @@ int interactive_add(int argc, const char **argv, const char *prefix)\n \treturn status;\n }\n \n-int edit_patch(int argc, const char **argv, const char *prefix)\n+static int edit_patch(int argc, const char **argv, const char *prefix)\n {\n \tchar *file = xstrdup(git_path(\"ADD_EDIT.patch\"));\n \tconst char *apply_argv[] = { \"apply\", \"--recount\", \"--cached\",\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 94ba2bd..bb59567 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -2614,7 +2614,7 @@ static int get_current_sha1(const char *path, unsigned char *sha1)\n static void build_fake_ancestor(struct patch *list, const char *filename)\n {\n \tstruct patch *patch;\n-\tstruct index_state result = { 0 };\n+\tstruct index_state result = { NULL };\n \tint fd;\n \n \t/* Once we start supporting the reverse patch, it may be\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 5c46496..2ceacb7 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -141,7 +141,7 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)\n \tif (is_bare) {\n \t\tstruct strbuf result = STRBUF_INIT;\n \t\tstrbuf_addf(&result, \"%.*s.git\", (int)(end - start), start);\n-\t\tdir = strbuf_detach(&result, 0);\n+\t\tdir = strbuf_detach(&result, NULL);\n \t} else\n \t\tdir = xstrndup(start, end - start);\n \t/*\ndiff --git a/builtin-fsck.c b/builtin-fsck.c\nindex 7da706c..e077e72 100644\n--- a/builtin-fsck.c\n+++ b/builtin-fsck.c\n@@ -104,7 +104,7 @@ static int mark_object(struct object *obj, int type, void *data)\n \n static void mark_object_reachable(struct object *obj)\n {\n-\tmark_object(obj, OBJ_ANY, 0);\n+\tmark_object(obj, OBJ_ANY, NULL);\n }\n \n static int traverse_one_object(struct object *obj, struct object *parent)\n@@ -292,7 +292,7 @@ static int fsck_sha1(const unsigned char *sha1)\n \t\tfprintf(stderr, \"Checking %s %s\\n\",\n \t\t\ttypename(obj->type), sha1_to_hex(obj->sha1));\n \n-\tif (fsck_walk(obj, mark_used, 0))\n+\tif (fsck_walk(obj, mark_used, NULL))\n \t\tobjerror(obj, \"broken links\");\n \tif (fsck_object(obj, check_strict, fsck_error_func))\n \t\treturn -1;\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 6e53b23..e1eba77 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -394,7 +394,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)\n  * HTML.\n  */\n #ifndef open_html\n-void open_html(const char *path)\n+static void open_html(const char *path)\n {\n \texecl_git_cmd(\"web--browse\", \"-c\", \"help.browser\", path, NULL);\n }\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 0d34050..44f9a27 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -94,7 +94,7 @@ static void show_early_header(struct rev_info *rev, const char *stage, int nr)\n \tprintf(\"Final output: %d %s\\n\", nr, stage);\n }\n \n-struct itimerval early_output_timer;\n+static struct itimerval early_output_timer;\n \n static void log_show_early(struct rev_info *revs, struct commit_list *list)\n {\n@@ -977,7 +977,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tstrbuf_addch(&buf, '\\n');\n \t}\n \n-\trev.extra_headers = strbuf_detach(&buf, 0);\n+\trev.extra_headers = strbuf_detach(&buf, NULL);\n \n \tif (start_number < 0)\n \t\tstart_number = 1;\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 793f2f4..af9adab 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -370,7 +370,7 @@ static void merge_name(const char *remote, struct strbuf *msg)\n \n \tstrbuf_addstr(&buf, \"refs/heads/\");\n \tstrbuf_addstr(&buf, remote);\n-\tresolve_ref(buf.buf, branch_head, 0, 0);\n+\tresolve_ref(buf.buf, branch_head, 0, NULL);\n \n \tif (!hashcmp(remote_head->sha1, branch_head)) {\n \t\tstrbuf_addf(msg, \"%s\\t\\tbranch '%s' of .\\n\",\n@@ -409,7 +409,7 @@ static void merge_name(const char *remote, struct strbuf *msg)\n \t\tstrbuf_addstr(&truname, \"refs/heads/\");\n \t\tstrbuf_addstr(&truname, remote);\n \t\tstrbuf_setlen(&truname, truname.len - len);\n-\t\tif (resolve_ref(truname.buf, buf_sha, 0, 0)) {\n+\t\tif (resolve_ref(truname.buf, buf_sha, 0, NULL)) {\n \t\t\tstrbuf_addf(msg,\n \t\t\t\t    \"%s\\t\\tbranch '%s'%s of .\\n\",\n \t\t\t\t    sha1_to_hex(remote_head->sha1),\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex dfc0b9e..f73c657 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -740,7 +740,7 @@ static int rm(int argc, const char **argv)\n \treturn result;\n }\n \n-void clear_push_info(void *util, const char *string)\n+static void clear_push_info(void *util, const char *string)\n {\n \tstruct push_info *info = util;\n \tfree(info->dest);\n@@ -815,7 +815,7 @@ struct show_info {\n \tint any_rebase;\n };\n \n-int add_remote_to_show_info(struct string_list_item *item, void *cb_data)\n+static int add_remote_to_show_info(struct string_list_item *item, void *cb_data)\n {\n \tstruct show_info *info = cb_data;\n \tint n = strlen(item->string);\n@@ -825,7 +825,7 @@ int add_remote_to_show_info(struct string_list_item *item, void *cb_data)\n \treturn 0;\n }\n \n-int show_remote_info_item(struct string_list_item *item, void *cb_data)\n+static int show_remote_info_item(struct string_list_item *item, void *cb_data)\n {\n \tstruct show_info *info = cb_data;\n \tstruct ref_states *states = info->states;\n@@ -852,7 +852,7 @@ int show_remote_info_item(struct string_list_item *item, void *cb_data)\n \treturn 0;\n }\n \n-int add_local_to_show_info(struct string_list_item *branch_item, void *cb_data)\n+static int add_local_to_show_info(struct string_list_item *branch_item, void *cb_data)\n {\n \tstruct show_info *show_info = cb_data;\n \tstruct ref_states *states = show_info->states;\n@@ -874,7 +874,7 @@ int add_local_to_show_info(struct string_list_item *branch_item, void *cb_data)\n \treturn 0;\n }\n \n-int show_local_info_item(struct string_list_item *item, void *cb_data)\n+static int show_local_info_item(struct string_list_item *item, void *cb_data)\n {\n \tstruct show_info *show_info = cb_data;\n \tstruct branch_info *branch_info = item->util;\n@@ -906,7 +906,7 @@ int show_local_info_item(struct string_list_item *item, void *cb_data)\n \treturn 0;\n }\n \n-int add_push_to_show_info(struct string_list_item *push_item, void *cb_data)\n+static int add_push_to_show_info(struct string_list_item *push_item, void *cb_data)\n {\n \tstruct show_info *show_info = cb_data;\n \tstruct push_info *push_info = push_item->util;\n@@ -935,7 +935,7 @@ static int cmp_string_with_push(const void *va, const void *vb)\n \treturn cmp ? cmp : strcmp(a_push->dest, b_push->dest);\n }\n \n-int show_push_info_item(struct string_list_item *item, void *cb_data)\n+static int show_push_info_item(struct string_list_item *item, void *cb_data)\n {\n \tstruct show_info *show_info = cb_data;\n \tstruct push_info *push_info = item->util;\n@@ -1187,7 +1187,7 @@ static int get_one_remote_for_update(struct remote *remote, void *priv)\n \treturn 0;\n }\n \n-struct remote_group {\n+static struct remote_group {\n \tconst char *name;\n \tstruct string_list *list;\n } remote_group;\ndiff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c\nindex 9a77323..f8d597d 100644\n--- a/builtin-unpack-objects.c\n+++ b/builtin-unpack-objects.c\n@@ -158,7 +158,7 @@ struct obj_info {\n #define FLAG_WRITTEN (1u<<21)\n \n static struct obj_info *obj_list;\n-unsigned nr_objects;\n+static unsigned nr_objects;\n \n /*\n  * Called only from check_object() after it verified this object\n@@ -200,7 +200,7 @@ static int check_object(struct object *obj, int type, void *data)\n \n \tif (fsck_object(obj, 1, fsck_error_function))\n \t\tdie(\"Error in object\");\n-\tif (!fsck_walk(obj, check_object, 0))\n+\tif (!fsck_walk(obj, check_object, NULL))\n \t\tdie(\"Error on reachable objects of %s\", sha1_to_hex(obj->sha1));\n \twrite_cached_object(obj);\n \treturn 1;\n@@ -210,7 +210,7 @@ static void write_rest(void)\n {\n \tunsigned i;\n \tfor (i = 0; i < nr_objects; i++)\n-\t\tcheck_object(obj_list[i].obj, OBJ_ANY, 0);\n+\t\tcheck_object(obj_list[i].obj, OBJ_ANY, NULL);\n }\n \n static void added_object(unsigned nr, enum object_type type,\ndiff --git a/connect.c b/connect.c\nindex 0ce941e..76e5427 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -464,7 +464,7 @@ static void git_proxy_connect(int fd[2], char *host)\n \n #define MAX_CMD_LEN 1024\n \n-char *get_port(char *host)\n+static char *get_port(char *host)\n {\n \tchar *end;\n \tchar *p = strchr(host, ':');\ndiff --git a/daemon.c b/daemon.c\nindex b2babcc..366db37 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -453,7 +453,7 @@ static void parse_host_arg(char *extra_args, int buflen)\n \t\tmemset(&hints, 0, sizeof(hints));\n \t\thints.ai_flags = AI_CANONNAME;\n \n-\t\tgai = getaddrinfo(hostname, 0, &hints, &ai);\n+\t\tgai = getaddrinfo(hostname, NULL, &hints, &ai);\n \t\tif (!gai) {\n \t\t\tstruct sockaddr_in *sin_addr = (void *)ai->ai_addr;\n \ndiff --git a/imap-send.c b/imap-send.c\nindex e4c83b9..3847fd1 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -238,7 +238,7 @@ static const char *Flags[] = {\n #ifndef NO_OPENSSL\n static void ssl_socket_perror(const char *func)\n {\n-\tfprintf(stderr, \"%s: %s\\n\", func, ERR_error_string(ERR_get_error(), 0));\n+\tfprintf(stderr, \"%s: %s\\n\", func, ERR_error_string(ERR_get_error(), NULL));\n }\n #endif\n \ndiff --git a/index-pack.c b/index-pack.c\nindex 6e93ee6..4d85aeb 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -469,7 +469,7 @@ static void sha1_object(const void *data, unsigned long size,\n \t\t\t\tdie(\"invalid %s\", typename(type));\n \t\t\tif (fsck_object(obj, 1, fsck_error_function))\n \t\t\t\tdie(\"Error in object\");\n-\t\t\tif (fsck_walk(obj, mark_link, 0))\n+\t\t\tif (fsck_walk(obj, mark_link, NULL))\n \t\t\t\tdie(\"Not all child objects of %s are reachable\", sha1_to_hex(obj->sha1));\n \n \t\t\tif (obj->type == OBJ_TREE) {\ndiff --git a/mailmap.c b/mailmap.c\nindex bb1f2fb..f167c00 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -103,7 +103,7 @@ static char *parse_name_and_email(char *buffer, char **name,\n \t\tchar **email, int allow_empty_email)\n {\n \tchar *left, *right, *nstart, *nend;\n-\t*name = *email = 0;\n+\t*name = *email = NULL;\n \n \tif ((left = strchr(buffer, '<')) == NULL)\n \t\treturn NULL;\n@@ -136,7 +136,7 @@ static int read_single_mailmap(struct string_list *map, const char *filename, ch\n \tif (f == NULL)\n \t\treturn 1;\n \twhile (fgets(buffer, sizeof(buffer), f) != NULL) {\n-\t\tchar *name1 = 0, *email1 = 0, *name2 = 0, *email2 = 0;\n+\t\tchar *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;\n \t\tif (buffer[0] == '#') {\n \t\t\tstatic const char abbrev[] = \"# repo-abbrev:\";\n \t\t\tint abblen = sizeof(abbrev) - 1;\n@@ -200,7 +200,7 @@ int map_user(struct string_list *map,\n \tif (!p) {\n \t\t/* email passed in might not be wrapped in <>, but end with a \\0 */\n \t\tp = memchr(email, '\\0', maxlen_email);\n-\t\tif (p == 0)\n+\t\tif (!p)\n \t\t\treturn 0;\n \t}\n \tif (p - email + 1 < sizeof(buf))\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex f5df9b9..c703445 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -38,7 +38,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two)\n  * A virtual commit has (const char *)commit->util set to the name.\n  */\n \n-struct commit *make_virtual_commit(struct tree *tree, const char *comment)\n+static struct commit *make_virtual_commit(struct tree *tree, const char *comment)\n {\n \tstruct commit *commit = xcalloc(1, sizeof(struct commit));\n \tcommit->tree = tree;\ndiff --git a/parse-options.c b/parse-options.c\nindex 79de18b..4eefdb1 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -478,7 +478,7 @@ static int usage_argh(const struct option *opts)\n #define USAGE_OPTS_WIDTH 24\n #define USAGE_GAP         2\n \n-int usage_with_options_internal(const char * const *usagestr,\n+static int usage_with_options_internal(const char * const *usagestr,\n \t\t\t\tconst struct option *opts, int full)\n {\n \tif (!usagestr)\ndiff --git a/quote.c b/quote.c\nindex 7a49fcf..48bce2e 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -272,8 +272,8 @@ void write_name_quoted(const char *name, FILE *fp, int terminator)\n \tfputc(terminator, fp);\n }\n \n-extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n-                                 const char *name, FILE *fp, int terminator)\n+void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n+                          const char *name, FILE *fp, int terminator)\n {\n \tint needquote = 0;\n \ndiff --git a/remote.c b/remote.c\nindex 08a5964..c2a2846 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -301,7 +301,7 @@ static void read_branches_file(struct remote *remote)\n \t\tstrbuf_addstr(&branch, \"HEAD:\");\n \t}\n \tadd_url_alias(remote, p);\n-\tadd_fetch_refspec(remote, strbuf_detach(&branch, 0));\n+\tadd_fetch_refspec(remote, strbuf_detach(&branch, NULL));\n \t/*\n \t * Cogito compatible push: push current HEAD to remote #branch\n \t * (master if missing)\n@@ -312,7 +312,7 @@ static void read_branches_file(struct remote *remote)\n \t\tstrbuf_addf(&branch, \":refs/heads/%s\", frag);\n \telse\n \t\tstrbuf_addstr(&branch, \":refs/heads/master\");\n-\tadd_push_refspec(remote, strbuf_detach(&branch, 0));\n+\tadd_push_refspec(remote, strbuf_detach(&branch, NULL));\n \tremote->fetch_tags = 1; /* always auto-follow */\n }\n \n@@ -1105,7 +1105,7 @@ int match_refs(struct ref *src, struct ref **dst,\n \tint send_all = flags & MATCH_REFS_ALL;\n \tint send_mirror = flags & MATCH_REFS_MIRROR;\n \tint errs;\n-\tstatic const char *default_refspec[] = { \":\", 0 };\n+\tstatic const char *default_refspec[] = { \":\", NULL };\n \tstruct ref **dst_tail = tail_ref(dst);\n \n \tif (!nr_refspec) {\ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex a90bc30..efa734b 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -9,7 +9,7 @@ static int verbose = 0, dry_run = 0, quiet = 0;\n static char *string = NULL;\n static char *file = NULL;\n \n-int length_callback(const struct option *opt, const char *arg, int unset)\n+static int length_callback(const struct option *opt, const char *arg, int unset)\n {\n \tprintf(\"Callback: \\\"%s\\\", %d\\n\",\n \t\t(arg ? arg : \"not set\"), unset);\n@@ -20,7 +20,7 @@ int length_callback(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n-int number_callback(const struct option *opt, const char *arg, int unset)\n+static int number_callback(const struct option *opt, const char *arg, int unset)\n {\n \t*(int *)opt->value = strtol(arg, NULL, 10);\n \treturn 0;\n"},{"id":"116591","messageId":"vpq8wjpzb9z.fsf@bauges.imag.fr","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906181021520.16802@localhost.localdomain","subject":"Re: Fix various sparse warnings in the git source code","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-06-18T17:45:12Z","receivedAt":"2009-06-18T17:45:12Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n>    Sparse wwants to see declarations for any functions you export. A lack \n>    fo a declaration tends to mean that you should either add one, or\n\nPatch content is good, but in case it matters, you can s/wwants/wants/\nand s/fo/for/ in the commit message.\n\n-- \nMatthieu\n"},{"id":"116590","messageId":"alpine.LFD.2.01.0906181049540.16802@localhost.localdomain","threadId":"19812","inReplyTo":"vpq8wjpzb9z.fsf@bauges.imag.fr","subject":"Re: Fix various sparse warnings in the git source code","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T17:52:17Z","receivedAt":"2009-06-18T17:52:17Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 18 Jun 2009, Matthieu Moy wrote:\n\n> Linus Torvalds <torvalds@linux-foundation.org> writes:\n> \n> >    Sparse wwants to see declarations for any functions you export. A lack \n> >    fo a declaration tends to mean that you should either add one, or\n> \n> Patch content is good, but in case it matters, you can s/wwants/wants/\n> and s/fo/for/ in the commit message.\n\nMy speling is gud, thak you vety much. I just miss a fwe keys.\n\nThat \"fo\" should not be \"for\", it should be \"of\".\n\nOf course, the \"wwants\" may not be a typo. Maybe it's like \"iff\": \"iff\" \nmeans \"if and only if\", and \"wants\" means \"wants and really wants\"?\n\nYou be the judge.\n\n\t\tLinus\n"},{"id":"116601","messageId":"alpine.LFD.2.01.0906181445530.16802@localhost.localdomain","threadId":"19812","inReplyTo":"alpine.LFD.2.01.0906181021520.16802@localhost.localdomain","subject":"Re: Fix various sparse warnings in the git source code","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-06-18T21:48:29Z","receivedAt":"2009-06-18T21:48:29Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 18 Jun 2009, Linus Torvalds wrote:\n> \n>  - warning: symbol 'xyz' was not declared. Should it be static?\n> \n>    Sparse wants to see declarations for any functions you export. A lack \n>    of a declaration tends to mean that you should either add one, or you \n>    should mark the function 'static' to show that it's in file scope. \n> \n>    A few of these remain: I only did the ones that should obviously just \n>    be made static.\n\nI don't know why I missed a couple.\n\nThat 'wt_status_submodule_summary' one is debatable. It has a few related \nflags (like 'wt_status_use_color') which _are_ declared, and are used by \nbuiltin-commit.c. So maybe we'd like to export it at some point, but it's \nnot declared now, and not used outside of that file, so 'static' it is in \nthis patch.\n\n\t\tLinus\n\n---\n http-push.c    |    2 +-\n unpack-trees.c |    2 +-\n wt-status.c    |    2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex e4ea395..8cc8ee0 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1750,7 +1750,7 @@ static int delete_remote_branch(char *pattern, int force)\n \treturn 0;\n }\n \n-void run_request_queue(void)\n+static void run_request_queue(void)\n {\n #ifdef USE_CURL_MULTI\n \tis_running_queue = 1;\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ac9927f..1958319 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -140,7 +140,7 @@ static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_option\n \treturn call_unpack_fn(src, o);\n }\n \n-int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)\n+static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)\n {\n \tint i;\n \tstruct tree_desc t[MAX_UNPACK_TREES];\ndiff --git a/wt-status.c b/wt-status.c\nindex 24a6abf..47735d8 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -13,7 +13,7 @@\n \n int wt_status_relative_paths = 1;\n int wt_status_use_color = -1;\n-int wt_status_submodule_summary;\n+static int wt_status_submodule_summary;\n static char wt_status_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_NORMAL, /* WT_STATUS_HEADER */\n \tGIT_COLOR_GREEN,  /* WT_STATUS_UPDATED */\n"}]}