[PATCH] Upstream: fix warning when building with BoringSSL

Maxim Dounin mdounin at mdounin.ru
Wed Oct 19 16:31:48 UTC 2016


On Wed, Oct 19, 2016 at 12:51:30AM -0700, Piotr Sikora wrote:

> Hey Maxim,
> > I have no strong objections, but the patch as you've submitted
> > casts to "const char *", while just "char *" should be enough.
> While cast to "char *" also works, I must admit that I'm confused as
> to why do you prefer to cast to a type that "should be enough" instead
> of a type that's expected by the function.

The "const char *" function argument essentially says: the 
argument is of type "char *", and this function will not modify 
it.  So casting to "char *" just casts to an appropriate type, while 
casting to "const char *" additionally adds a guard that the 
function used still promises not to modify arguments.  Certainly 
there is no need for such a guard here.

Or, from more practical point of view, "char *" works with "const 
char *" argument, but the opposite is not true.  And any change of 
the function arguments, perhaps unintentional, e.g., if the macro 
promoted to a function in another library, but without "const" 
added, will break things.

> Anyway, either one is an improvement over current situation, so please commit.

Committed, thank you for prodding this.

Maxim Dounin

More information about the nginx-devel mailing list