All,
On 5/5/22 08:27, Christopher Schultz wrote:
All,
When compiling with these extra flags, we get a raft of errors which are
mostly:
1. Use of "long long" which is an "extension"
2. Use of // style comments
3. Use of mixed declarations and code
When setting -std=C99 all of these go away. This flag works with both
gcc and clang, but I don't know how many other systems and compilers we
expect to support.
Are we requiring the use of a C99-compliant compiler? If so, we probably
want to add one or more CFLAGS to make that explicit.
For 1.2.34, I again used --std=c99 -Wall -pedantic to build and I
noticed this on gcc under Linux:
os/unix/system.c: In function ‘Java_org_apache_tomcat_jni_OS_info’:
os/unix/system.c:174:41: warning: format ‘%llu’ expects argument of type
‘long long unsigned int *’, but argument 5 has type ‘long long int *’
[-Wformat=]
174 | if (sscanf(buf, "%*d %*s %*c %*d %*d
%*d %*d %*d %*u"
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
178 | "%llu", &user, &system,
&starttime) == 3) {
|
~~~~~~~~~~
| |
|
long long int *
os/unix/system.c:178:45: note: format string is defined here
178 | "%llu", &user, &system,
&starttime) == 3) {
| ~~~^
| |
| long long unsigned
int *
| %llu
On system.c:176 there is this comment:
174 * utime %lu (!), stime %lu (!), cutime %ld (!), cstime %ld (!),
175 * priority %ld, nice %ld, num_threads %ld, itrealvalue %ld,
176 * starttime %llu (!) */
Note the (!) in the comment. I'm not sure if that's meant to indicate a
known issue with the variable and format or not. There are similar (!)
notations on line 174 for each of those items.
Rainer laid that code into os/unix/system.c all at once back in 2012.
tcnative uses that starttime value to compute the process-start time
value. All other participants in the computation are apr_time_t
(apr_int64_t - signed), long (signed), so I think starttime should be
signed as well. (Honestly, unsigned makes more sense IMO but everything
else is signed.)
It's only the scanf format that looks wrong: it's "%llu" and should
probably be "%lld".
WDYT?
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org