library: eliminated the questionable 'procps.h' header

There was a time when that procps.h file served a more
traditional role. Prior to the commit referenced below
it held just macros plus manifest constants. But, with
that change, such items were replaced with a series of
includes embracing all the library exported functions.

That approach was known to disguise errors which would
have otherwise yielded a compiler warning. And without
such a warning, there was no way to address the error.

So this patch will trade the all inclusive header file
approach for individual includes only where necessary.

Reference(s):
. April 2016, procps.h header file revamped
commit ccb6ae8de1
. Sept 2018, top abandoned use of procps.h
commit a6dfc2382e

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-06-30 00:00:00 -05:00 committed by Craig Small
parent 70fd03e461
commit 1aa8b16441
18 changed files with 62 additions and 78 deletions

View File

@ -252,7 +252,6 @@ proc_libprocps_la_SOURCES = \
proc/numa.h \
proc/pids.c \
proc/pids.h \
proc/procps.h \
proc/pwcache.c \
proc/pwcache.h \
proc/readproc.c \
@ -282,7 +281,6 @@ proc_libprocps_la_include_HEADERS = \
proc/namespace.h \
proc/numa.h \
proc/pids.h \
proc/procps.h \
proc/pwcache.h \
proc/readproc.h \
proc/slabinfo.h \

14
free.c
View File

@ -26,12 +26,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "c.h"
#include "nls.h"
#include "strutils.h"
#include "fileutils.h"
#include <locale.h>
#include <errno.h>
#include <limits.h>
@ -41,7 +35,13 @@
#include <stdlib.h>
#include <unistd.h>
#include <proc/procps.h>
#include "config.h"
#include "c.h"
#include "nls.h"
#include "strutils.h"
#include "fileutils.h"
#include <proc/meminfo.h>
#ifndef SIZE_MAX
#define SIZE_MAX 32

View File

@ -49,7 +49,10 @@
#include "nls.h"
#include "signals.h"
#include "xalloc.h"
#include <proc/procps.h>
#include <proc/namespace.h>
#include <proc/pids.h>
#include <proc/uptime.h>
enum pids_item Items[] = {
PIDS_ID_PID,

View File

@ -28,7 +28,8 @@
#include "fileutils.h"
#include "nls.h"
#include "xalloc.h"
#include <proc/procps.h>
#include <proc/pids.h>
#define grow_size(x) do { \

3
pmap.c
View File

@ -36,7 +36,8 @@
#include "fileutils.h"
#include "nls.h"
#include "xalloc.h"
#include <proc/procps.h>
#include <proc/pids.h>
static struct pids_info *Pids_info;

View File

@ -21,7 +21,6 @@
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <proc/procps.h>
#include "escape.h"
#include "readproc.h"

View File

@ -8,7 +8,9 @@
#define ESC_BRACKETS 0x2 // if using cmd, put '[' and ']' around it
#define ESC_DEFUNCT 0x4 // mark zombies with " <defunct>"
int escape_command(char *__restrict const outbuf, const proc_t *__restrict const pp, int bytes, int *cells, unsigned flags);
#define ESC_STRETCH 1 // since we mangle to '?' this is 1 (would be 4 for octal escapes)
int escape_str(char *__restrict dst, const char *__restrict src, int bufsize, int *maxcells);
#endif

View File

@ -1,37 +0,0 @@
/*
* libprocps - Library to read proc filesystem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PROCPS_PROC_PROCPS_H
#define PROCPS_PROC_PROCPS_H
/* includes that show public exports go here */
#include <proc/diskstats.h>
#include <proc/meminfo.h>
#include <proc/namespace.h>
#include <proc/pids.h>
#include <proc/slabinfo.h>
#include <proc/stat.h>
#include <proc/sysinfo.h>
#include <proc/version.h>
#include <proc/vmstat.h>
#include <proc/uptime.h>
// FIXME: only public function in escape.c
#define ESC_STRETCH 1 // since we mangle to '?' this is 1 (would be 4 for octal escapes)
int escape_str(char *__restrict dst, const char *__restrict src, int bufsize, int *maxcells);
#endif

View File

@ -19,12 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "version.h"
#include "readproc.h"
#include "escape.h"
#include "pwcache.h"
#include "devname.h"
#include "procps.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@ -41,7 +35,13 @@
#ifdef WITH_SYSTEMD
#include <systemd/sd-login.h>
#endif
#include <proc/namespace.h>
#include "devname.h"
#include "escape.h"
#include "namespace.h"
#include "pwcache.h"
#include "readproc.h"
#include "version.h"
// sometimes it's easier to do this manually, w/o gcc helping
#ifdef PROF

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <proc/procps.h>
#include <proc/namespace.h>
#include "tests.h"
int check_name_minus(void *data)

View File

@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <proc/procps.h>
#include <proc/uptime.h>
#include "tests.h"
int check_uptime(void *data)

View File

@ -13,7 +13,11 @@
#define PROCPS_PS_H
#include "../include/nls.h"
#include <proc/procps.h>
#include <proc/escape.h>
#include <proc/meminfo.h>
#include <proc/pids.h>
#include <proc/stat.h>
#include <proc/sysinfo.h>
// --- <pids> interface begin ||||||||||||||||||||||||||||||||||||||||||||
// -----------------------------------------------------------------------

View File

@ -34,8 +34,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <proc/procps.h>
#include "c.h"
#include "fileutils.h"
#include "signals.h"
@ -44,6 +42,9 @@
#include "xalloc.h"
#include "rpmatch.h"
#include <proc/namespace.h>
#include <proc/pids.h>
#define DEFAULT_NICE 4
struct run_time_conf_t {

View File

@ -42,7 +42,8 @@
#include "fileutils.h"
#include "nls.h"
#include "strutils.h"
#include <proc/procps.h>
#include <proc/slabinfo.h>
#define DEFAULT_SORT SLAB_NUM_OBJS
#define CHAINS_ALLOC 150

15
tload.c
View File

@ -24,13 +24,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <proc/procps.h>
#include "c.h"
#include "fileutils.h"
#include "nls.h"
#include "strutils.h"
#include "xalloc.h"
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@ -44,6 +37,14 @@
#include <unistd.h>
#include <limits.h>
#include "c.h"
#include "fileutils.h"
#include "nls.h"
#include "strutils.h"
#include "xalloc.h"
#include <proc/sysinfo.h>
static char *screen;
static int nrows = 25;

View File

@ -27,7 +27,8 @@
#include "c.h"
#include "fileutils.h"
#include "nls.h"
#include <proc/procps.h>
#include <proc/uptime.h>
static void print_uptime_since()
{

View File

@ -48,7 +48,13 @@
#include "fileutils.h"
#include "nls.h"
#include "strutils.h"
#include <proc/procps.h>
#include <proc/diskstats.h>
#include <proc/meminfo.h>
#include <proc/slabinfo.h>
#include <proc/stat.h>
#include <proc/sysinfo.h>
#include <proc/vmstat.h>
#define UNIT_B 1
#define UNIT_k 1000

13
w.c
View File

@ -23,11 +23,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "c.h"
#include "fileutils.h"
#include "nls.h"
#include <proc/procps.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@ -51,6 +46,14 @@
#include <utmp.h>
#include <arpa/inet.h>
#include "c.h"
#include "fileutils.h"
#include "nls.h"
#include <proc/pids.h>
#include <proc/sysinfo.h>
#include <proc/uptime.h>
static int ignoreuser = 0; /* for '-u' */
static int oldstyle = 0; /* for '-o' */