{"thread":{"id":"14879","subject":"On PPC64, the parsing of integers on the commandline is bitshifted.","startedAt":"2008-08-07T20:31:22Z","lastAt":"2008-08-08T08:38:04Z","messageCount":5,"participants":["Robin H. Johnson","Brandon Casey","Junio C Hamano","Pierre Habouzit"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"86437","messageId":"20080807203122.GR22707@curie-int.orbis-terrarum.net","threadId":"14879","inReplyTo":null,"subject":"On PPC64, the parsing of integers on the commandline is bitshifted.","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2008-08-07T20:31:22Z","receivedAt":"2008-08-07T20:31:22Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"In a 64-bit userland, big-endian environment, the parser gets integers\nwrong.\n\n# ./test-parse-options --set23 |grep integer\ninteger: 98784247808\n# patch ...\n# ./test-parse-options --set23 |grep integer\ninteger: 23\n\nFull failures from the testcases\n-integer: 1729\n+integer: 7425998454784\n-integer: 13\n+integer: 55834574848\n-integer: 2\n+integer: 8589934592\n-integer: 23\n+integer: 98784247808\n\nAll the values are shifted up 32 bits.\n\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\n\n---\nPlease CC me in replies, I'm not on git@vger.\n\nFix against 1.5.6.4:\n--- parse-options.c.orig\t2008-08-07 14:51:17.000000000 -0500\n+++ parse-options.c\t2008-08-07 14:51:25.000000000 -0500\n@@ -78,7 +78,7 @@\n \t\treturn 0;\n \n \tcase OPTION_SET_INT:\n-\t\t*(int *)opt->value = unset ? 0 : opt->defval;\n+\t\t*(long int *)opt->value = unset ? 0 : opt->defval;\n \t\treturn 0;\n \n \tcase OPTION_SET_PTR:\n\n-- \nRobin Hugh Johnson\nGentoo Linux Developer & Infra Guy\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"86438","messageId":"X68iwLodMeAo1RYVJdU3iyNzAFylpDRpP1jkviJTeiOnoNs5n2qZcg@cipher.nrlssc.navy.mil","threadId":"14879","inReplyTo":"20080807203122.GR22707@curie-int.orbis-terrarum.net","subject":"Re: On PPC64, the parsing of integers on the commandline is bitshifted.","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-07T21:26:15Z","receivedAt":"2008-08-07T21:26:15Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Robin H. Johnson wrote:\n> In a 64-bit userland, big-endian environment, the parser gets integers\n> wrong.\n\nThere is a fix on master. Can you try that out?\nUnfortunately, looks like it did not make it into 1.5.6.5\n\n-brandon\n"},{"id":"86439","messageId":"CxVxAoKmEQsrgFdHEvL0sjkgBBIVZ3Zvsl0pPSuDSfH_8xM8NOSGfw@cipher.nrlssc.navy.mil","threadId":"14879","inReplyTo":"X68iwLodMeAo1RYVJdU3iyNzAFylpDRpP1jkviJTeiOnoNs5n2qZcg@cipher.nrlssc.navy.mil","subject":"Re: On PPC64, the parsing of integers on the commandline is bitshifted.","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-07T21:34:00Z","receivedAt":"2008-08-07T21:34:00Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n> Robin H. Johnson wrote:\n>> In a 64-bit userland, big-endian environment, the parser gets integers\n>> wrong.\n> \n> There is a fix on master. Can you try that out?\n> Unfortunately, looks like it did not make it into 1.5.6.5\n\nAlso, just so you know, it is test-parse-options.c that is broken, not\nthe parsing code. So, the rest of git should be using an int with\nOPT_INTEGER() and should operate correctly.\n\n-brandon\n"},{"id":"86440","messageId":"7vhc9wijsq.fsf@gitster.siamese.dyndns.org","threadId":"14879","inReplyTo":"CxVxAoKmEQsrgFdHEvL0sjkgBBIVZ3Zvsl0pPSuDSfH_8xM8NOSGfw@cipher.nrlssc.navy.mil","subject":"Re: On PPC64, the parsing of integers on the commandline is bitshifted.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-07T21:42:29Z","receivedAt":"2008-08-07T21:42:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> Brandon Casey wrote:\n>> Robin H. Johnson wrote:\n>>> In a 64-bit userland, big-endian environment, the parser gets integers\n>>> wrong.\n>> \n>> There is a fix on master. Can you try that out?\n>> Unfortunately, looks like it did not make it into 1.5.6.5\n>\n> Also, just so you know, it is test-parse-options.c that is broken, not\n> the parsing code. So, the rest of git should be using an int with\n> OPT_INTEGER() and should operate correctly.\n\nYup, that is why it is not on 'maint' --- but somebody should audit the\nparse_options() users in the real programs to make sure that there is no\nsimilar breakages, namely, giving a pointer to long to OPT_INTEGER().\n"},{"id":"86466","messageId":"20080808083804.GB13578@artemis.madism.org","threadId":"14879","inReplyTo":"7vhc9wijsq.fsf@gitster.siamese.dyndns.org","subject":"Re: On PPC64, the parsing of integers on the commandline is bitshifted.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-08-08T08:38:04Z","receivedAt":"2008-08-08T08:38:04Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Thu, Aug 07, 2008 at 09:42:29PM +0000, Junio C Hamano wrote:\n> Brandon Casey <casey@nrlssc.navy.mil> writes:\n> \n> > Brandon Casey wrote:\n> >> Robin H. Johnson wrote:\n> >>> In a 64-bit userland, big-endian environment, the parser gets integers\n> >>> wrong.\n> >> \n> >> There is a fix on master. Can you try that out?\n> >> Unfortunately, looks like it did not make it into 1.5.6.5\n> >\n> > Also, just so you know, it is test-parse-options.c that is broken, not\n> > the parsing code. So, the rest of git should be using an int with\n> > OPT_INTEGER() and should operate correctly.\n> \n> Yup, that is why it is not on 'maint' --- but somebody should audit the\n> parse_options() users in the real programs to make sure that there is no\n> similar breakages, namely, giving a pointer to long to OPT_INTEGER().\n\n  Well FWIW I'll probably write some __GNUC__ guarded glue using\n__builtin_types_compatible and friends to ensure we're not passing crap\nto the OPT_* macros. I just didn't have time to yet.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"}]}