Fix warnings with lib/libpmc
* Use `MIN` instead of similar hand rolled macro. * Sort headers. * Use `errno.h` instead of `sys/errno.h`. * Wrap the argument to sizeof in parentheses for clarity. * Remove `__BSD_VISIBLE` and `_XOPEN_SOURCE` #defines to mute warnings about incompatible snprintf definitions. This fixes a number of warnings I've been seeing lately in my builds. Sort makefile variables per style.Makefile(9) (`CFLAGS`/`CWARNFLAG.gcc`) and bump `WARNS` to 3. MFC after: 2 weeks Reviewed by: jtl Approved by: jtl (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D19851
This commit is contained in:
parent
f0dfbcccf4
commit
b3d01a2ad7
@ -6,9 +6,6 @@ LIB= pmc
|
||||
SRCS= libpmc.c pmclog.c libpmc_pmu_util.c libpmc_json.cc
|
||||
INCS= pmc.h pmclog.h pmcformat.h
|
||||
|
||||
CFLAGS+= -I${.CURDIR}
|
||||
CWARNFLAGS.gcc+= -Wno-shadow -Wno-cast-align
|
||||
|
||||
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
|
||||
|
||||
.if ${MACHINE_ARCH} == "aarch64"
|
||||
@ -31,6 +28,11 @@ libpmc_events.c: ${JEVENTS}
|
||||
SRCS+= libpmc_events.c
|
||||
.endif
|
||||
|
||||
WARNS?= 3
|
||||
|
||||
CFLAGS+= -I${.CURDIR}
|
||||
CWARNFLAGS.gcc+= -Wno-shadow -Wno-cast-align
|
||||
|
||||
MAN= pmc.3
|
||||
MAN+= pmc_allocate.3
|
||||
MAN+= pmc_attach.3
|
||||
|
3
lib/libpmc/Makefile.inc
Normal file
3
lib/libpmc/Makefile.inc
Normal file
@ -0,0 +1,3 @@
|
||||
# $FreeBSD$
|
||||
|
||||
WARNS?= 3
|
@ -29,19 +29,21 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <pmc.h>
|
||||
#include <pmclog.h>
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <sysexits.h>
|
||||
|
||||
#include <pmc.h>
|
||||
#include <pmcformat.h>
|
||||
#include <pmclog.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define _XOPEN_SOURCE 500 /* needed for nftw() */
|
||||
#define __BSD_VISIBLE 1 /* needed for asprintf() */
|
||||
/* Parse event JSON files */
|
||||
|
||||
/*
|
||||
@ -33,22 +31,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/resource.h> /* getrlimit */
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h> /* getrlimit */
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/time.h> /* getrlimit */
|
||||
#include <sys/resource.h> /* getrlimit */
|
||||
#include <ftw.h>
|
||||
#include <sys/stat.h>
|
||||
#include "list.h"
|
||||
#include "jsmn.h"
|
||||
#include "json.h"
|
||||
@ -641,7 +639,7 @@ int json_events(const char *fn,
|
||||
addfield(map, &extra_desc, " ",
|
||||
"(Precise event)", NULL);
|
||||
}
|
||||
snprintf(buf, sizeof buf, "event=%#llx", eventcode);
|
||||
snprintf(buf, sizeof(buf), "event=%#llx", eventcode);
|
||||
addfield(map, &event, ",", buf, NULL);
|
||||
if (desc && extra_desc)
|
||||
addfield(map, &desc, " ", extra_desc, NULL);
|
||||
@ -866,7 +864,7 @@ static int get_maxfds(void)
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
|
||||
if (rlim.rlim_max == RLIM_INFINITY)
|
||||
return 512;
|
||||
return min((unsigned)rlim.rlim_max / 2, 512);
|
||||
return MIN(rlim.rlim_max / 2, 512);
|
||||
}
|
||||
|
||||
return 512;
|
||||
|
@ -11,12 +11,4 @@ int json_events(const char *fn,
|
||||
void *data);
|
||||
char *get_cpu_str(void);
|
||||
|
||||
#ifndef min
|
||||
#define min(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user