{"thread":{"id":"43507","subject":"[PATCH 1/2] Use ULONG_MAX rather than implicit cast of -1.","startedAt":"2006-11-05T07:18:05Z","lastAt":"2006-11-05T07:27:07Z","messageCount":2,"participants":["Shawn O. Pearce","Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"295538","messageId":"20061105071805.GA4506@spearce.org","threadId":"43507","inReplyTo":"7v3b8ywewj.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/3] Apply obvious numerical cast for stupid C compilers.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-05T07:18:05Z","receivedAt":"2006-11-05T07:18:05Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > At least one (older) version of the Solaris C compiler won't allow\n> > 'unsigned long x = -1' without explicitly casting -1 to a type of\n> > unsigned long.  As annoying as it may be to explicitly perform the\n> > cast the compiler is right; -1 is not an unsigned value.\n> \n> Is the compiler really _right_?  The usual integral promotion\n> rules should apply if it claims to be a C compiler, I would\n> think.\n\nI'm rusty on my C; but I would expect an error if I tried to assign\na clearly negative value into an unsigned value, especially in a\ncase like this.  It could be compiler is wrong, but as a programmer\nI'd want to know I wrote something stupid like that, because maybe\nthe variable should have been signed.  :-)\n \n> But I think the code actually wants ULONG_MAX there.  Is that\n> symbolic constant available at the point of offending\n> initialization with the header files we already include, I\n> wonder.\n\nYes, I agree.  I almost changed it to ULONG_MAX but didn't since\nthe original author felt -1 was the better choice here.  *shrug*\n\nFor what its worth ULONG_MAX works on my Mac OS X system.\n\nTomorrow when I have access to that \"broken\" platform again I'll\ntry ULONG_MAX and see if it compiles there.\n\n-- \n"},{"id":"295179","messageId":"20061105072707.GA4579@spearce.org","threadId":"43507","inReplyTo":"20061105071805.GA4506@spearce.org","subject":"[PATCH 1/2] Use ULONG_MAX rather than implicit cast of -1.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-05T07:27:07Z","receivedAt":"2006-11-05T07:27:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"At least one (older) version of the Solaris C compiler won't allow\n'unsigned long x = -1' without explicitly casting -1 to a type of\nunsigned long.  So instead use ULONG_MAX, which is really the\ncorrect constant anyway.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n This is a resend of my earlier patch in in this same thread...\n\n builtin-apply.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex db7cdce..aad5526 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -43,7 +43,7 @@ static int apply_verbosely;\n static int no_add;\n static int show_index_info;\n static int line_termination = '\\n';\n-static unsigned long p_context = -1;\n+static unsigned long p_context = ULONG_MAX;\n static const char apply_usage[] =\n \"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...\";\n \n-- \n1.4.3.3.g9621\n"}]}