mirror of
https://gitlab.com/procps-ng/procps.git
synced 2024-11-27 12:04:28 +08:00
library: fix 'smaps' bug preventing a build with clang
As a result of the issue referenced below, we'll trade our homegrown offset generator for an 'offsetof' macro found in the stddef.h header file. This pleases clang. [ and thanks to Daniel Kolesa for the report and fix ] Reference(s): . bug report & recommended solution https://gitlab.com/procps-ng/procps/-/issues/235 . clang error message proc/readproc.c:673:9: error: initializer element is not a compile-time constant mkENT(Rss), ^~~~~~~~~~ proc/readproc.c:661:34: note: expanded from macro 'mkENT' #define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
7279cd8e4d
commit
9e77e138c1
1
NEWS
1
NEWS
@ -4,6 +4,7 @@ procps-ng-NEXT
|
||||
* ps: threads again display when -L is used with -q issue #234
|
||||
* ps: proper aix format string behavior was restored
|
||||
* sysctl: print dotted keys again
|
||||
* top: fix 'smaps' bug preventing build under clang issue #235
|
||||
|
||||
procps-ng-4.0.0
|
||||
---------------
|
||||
|
@ -19,6 +19,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
@ -658,10 +659,9 @@ static void smaps2proc (const char *s, proc_t *restrict P) {
|
||||
// 1st proc_t data field
|
||||
#define fZERO tid
|
||||
// a smaptab entry generator
|
||||
#define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) }
|
||||
#define mkENT(F) { #F ":", -1, offsetof(proc_t, smap_ ## F) }
|
||||
// make a target field
|
||||
#define mkOBJ(X) ( (unsigned long *)((void *)&P->fZERO + smaptab[X].offs) )
|
||||
static const proc_t *q;
|
||||
static struct {
|
||||
const char *item;
|
||||
int slen;
|
||||
|
Loading…
Reference in New Issue
Block a user