RFR: 8146115 - Improve docker container detection and resource configuration usage

Bob Vandette bob.vandette at oracle.com
Tue Oct 24 14:11:43 UTC 2017


> On Oct 23, 2017, at 12:52 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
> 
>> On Sep 27, 2017, at 9:20 PM, David Holmes <david.holmes at oracle.com> wrote:
>>>> 62     void set_subsystem_path(char *cgroup_path) {
>>>> 
>>>> If this takes a "const char*" will it save you from casting string literals to "char*" elsewhere?
>>> I tried several different ways of declaring the container accessor functions and
>>> always ended up with warnings due to scanf not being able to validate arguments
>>> since the format string didn’t end up being a string literal.  I originally was using templates
>>> and then ended up with the macros.  I tried several different casts but could resolve the problem.
>> 
>> Sounds like something Kim Barrett should take a look at :)
> 
> Fortunately, I just happened by.
> 
> The warnings are because we compile with -Wformat=2, which enables
> -Wformat-nonliteral (among other things).
> 
> Use PRAGMA_FORMAT_NONLITERAL_IGNORED, e.g.
> 
> PRAGMA_DIAG_PUSH
> PRAGMA_FORMAT_NONLITERAL_IGNORED
> <function definition>
> PRAGMA_DIAG_POP
> 
> That will silence warnings about sscanf (or anything else!) with a
> non-literal format string within that <function definition>.

Thanks but I ended up taking a different approach that resulted in more compact code.

http://cr.openjdk.java.net/~bobv/8146115/webrev.02 <http://cr.openjdk.java.net/~bobv/8146115/webrev.02>

> 
> Also, while I was looking at this, I noticed that in
> get_subsytem_file_contents_##return_name, if the sum of the lengths of
> get_subsystem_path() and filename is >= MAXBUF, then we can end up
> reading from a file other than the one intended, if such a file
> exists.  That seems like it might be bad.

I fixed all uses of strncat.

> 
> Also, the filename argument should be const char*.
> 

Fixed.

Thanks,
Bob.



More information about the hotspot-dev mailing list