mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: Johannes Schindelin <>
Cc: Jeff King <>,
	Johannes Schindelin via GitGitGadget <>,
Subject: Re: [PATCH 1/2] pkt-line: fix declaration of `set_packet_header()`
Date: Thu, 16 May 2019 11:24:25 +0900	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Johannes Schindelin's message of "Wed, 15 May 2019 12:39:04 +0200 (DST)")

Johannes Schindelin <> writes:

>> lacked the "const" for that reason, but apparently some compilers
>> complain about the parameter type mismatch.
> We could be more explicit, as we know exactly that it is MS Visual C 2017
> that is complaining.

We could be, but I do not see a point of shaming one particular
compiler vendor.

>> Let's squelch it by removing the "const" that is pointless for a
>> small function like this, which would not help optimizing compilers
> It is not pointless because of the size of the function, but because `int`
> is already a type that is always passed by value, never by reference.

You are looking only at the prototype side (i.e. declaration in
*.h).  Yes it is pointless for the callers.  For the callee, the
story is different and pass-by-value does not even get in the

The mention of pointless-ness I made was about the implementation
side (i.e. definition in *.c).  For a sufficiently large and complex
function implementation, being able to say upfront that this
incoming parameter is never modified would help following the logic
in the implementation, so "const int param" in the parameter list of
a definition is *not* pointless in general.  But apparently some
compilers are not happy abot "const int param" in implementation
that is paired with "int param" in prototype, we are dropping a
const that could be useful, with an excuse that for this particular
function that is small and trivial, we can live without.

  reply	other threads:[~2019-05-16  2:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 22:43 [PATCH 0/2] pkt-line: fix incorrect function declaration Johannes Schindelin via GitGitGadget
2019-05-13 22:43 ` [PATCH 1/2] pkt-line: fix declaration of `set_packet_header()` Johannes Schindelin via GitGitGadget
2019-05-13 23:24   ` Junio C Hamano
2019-05-14 12:57     ` Johannes Schindelin
2019-05-14 14:43       ` Jeff King
2019-05-14 14:44         ` Jeff King
2019-05-15  1:42         ` Junio C Hamano
2019-05-15  1:44           ` Jeff King
2019-05-15 10:39           ` Johannes Schindelin
2019-05-16  2:24             ` Junio C Hamano [this message]
2019-05-16  3:42               ` Jeff King
2019-05-16  4:28                 ` Junio C Hamano
2019-05-17 18:54               ` Johannes Schindelin
2019-05-13 22:43 ` [PATCH 2/2] parse-options: adjust `parse_opt_unknown_cb()`s declared return type Johannes Schindelin via GitGitGadget
2019-05-13 23:29   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).