mirror of https://github.com/xzeldon/htop.git
Merge branch 'attr-nonnull' of https://github.com/BenBE/htop into BenBE-attr-nonnull
This commit is contained in:
commit
576b82f86a
|
@ -6,6 +6,8 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "Affinity.h"
|
#include "Affinity.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -7,10 +7,10 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Settings.h"
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "ScreenManager.h"
|
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
|
#include "ScreenManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
typedef struct AvailableMetersPanel_ {
|
typedef struct AvailableMetersPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
|
@ -8,9 +8,9 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "ScreenManager.h"
|
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
|
#include "ScreenManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
typedef struct CategoriesPanel_ {
|
typedef struct CategoriesPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
|
@ -8,8 +8,8 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
typedef struct ColorsPanel_ {
|
typedef struct ColorsPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
|
@ -8,8 +8,8 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
typedef struct DisplayOptionsPanel_ {
|
typedef struct DisplayOptionsPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
3
IncSet.h
3
IncSet.h
|
@ -7,9 +7,10 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "FunctionBar.h"
|
#include "FunctionBar.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#define INCMODE_MAX 40
|
#define INCMODE_MAX 40
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef HEADER_InfoScreen
|
#ifndef HEADER_InfoScreen
|
||||||
#define HEADER_InfoScreen
|
#define HEADER_InfoScreen
|
||||||
|
|
||||||
#include "Process.h"
|
|
||||||
#include "Panel.h"
|
|
||||||
#include "FunctionBar.h"
|
#include "FunctionBar.h"
|
||||||
#include "IncSet.h"
|
#include "IncSet.h"
|
||||||
|
#include "Panel.h"
|
||||||
|
#include "Process.h"
|
||||||
|
|
||||||
typedef struct InfoScreen_ InfoScreen;
|
typedef struct InfoScreen_ InfoScreen;
|
||||||
|
|
||||||
|
|
3
Meter.h
3
Meter.h
|
@ -7,9 +7,10 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ListItem.h"
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "ListItem.h"
|
||||||
|
|
||||||
#define METER_BUFFER_LEN 256
|
#define METER_BUFFER_LEN 256
|
||||||
|
|
||||||
typedef struct Meter_ Meter;
|
typedef struct Meter_ Meter;
|
||||||
|
|
|
@ -8,8 +8,8 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
typedef struct MetersPanel_ MetersPanel;
|
typedef struct MetersPanel_ MetersPanel;
|
||||||
|
|
||||||
|
|
2
Panel.h
2
Panel.h
|
@ -7,9 +7,9 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "FunctionBar.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
#include "FunctionBar.h"
|
|
||||||
|
|
||||||
typedef struct Panel_ Panel;
|
typedef struct Panel_ Panel;
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ in the source distribution for its full text.
|
||||||
#endif
|
#endif
|
||||||
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
|
||||||
|
|
||||||
#include "Object.h"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
#define PROCESS_FLAG_IO 0x0001
|
#define PROCESS_FLAG_IO 0x0001
|
||||||
|
|
||||||
typedef enum ProcessFields {
|
typedef enum ProcessFields {
|
||||||
|
|
|
@ -7,12 +7,12 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Vector.h"
|
|
||||||
#include "Hashtable.h"
|
#include "Hashtable.h"
|
||||||
#include "UsersTable.h"
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "UsersTable.h"
|
||||||
|
#include "Vector.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBHWLOC
|
#ifdef HAVE_LIBHWLOC
|
||||||
#include <hwloc.h>
|
#include <hwloc.h>
|
||||||
|
|
|
@ -7,10 +7,10 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Vector.h"
|
|
||||||
#include "Header.h"
|
#include "Header.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
|
#include "Vector.h"
|
||||||
|
|
||||||
typedef enum Orientation_ {
|
typedef enum Orientation_ {
|
||||||
VERTICAL,
|
VERTICAL,
|
||||||
|
|
|
@ -9,9 +9,10 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#define DEFAULT_DELAY 15
|
#define DEFAULT_DELAY 15
|
||||||
|
|
||||||
#include "Process.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "Process.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int len;
|
int len;
|
||||||
char** names;
|
char** names;
|
||||||
|
|
30
XAlloc.c
30
XAlloc.c
|
@ -5,6 +5,8 @@
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -39,7 +41,33 @@ void* xRealloc(void* ptr, size_t size) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* xStrdup_(const char* str) {
|
int xAsprintf(char** strp, const char* fmt, ...) {
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, fmt);
|
||||||
|
int _r = vasprintf(strp, fmt, vl);
|
||||||
|
va_end(vl);
|
||||||
|
|
||||||
|
if (_r < 0) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int xSnprintf(char* buf, int len, const char* fmt, ...) {
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, fmt);
|
||||||
|
int _n=vsnprintf(buf, len, fmt, vl);
|
||||||
|
va_end(vl);
|
||||||
|
|
||||||
|
if (!(_n > -1 && _n < len)) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _n;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* xStrdup(const char* str) {
|
||||||
char* data = strdup(str);
|
char* data = strdup(str);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
fail();
|
fail();
|
||||||
|
|
20
XAlloc.h
20
XAlloc.h
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include "Macros.h"
|
#include "Macros.h"
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void fail(void) ATTR_NORETURN;
|
void fail(void) ATTR_NORETURN;
|
||||||
|
@ -19,20 +19,12 @@ void* xCalloc(size_t nmemb, size_t size);
|
||||||
|
|
||||||
void* xRealloc(void* ptr, size_t size);
|
void* xRealloc(void* ptr, size_t size);
|
||||||
|
|
||||||
#undef xAsprintf
|
ATTR_FORMAT(printf, 2, 3)
|
||||||
|
int xAsprintf(char **strp, const char* fmt, ...);
|
||||||
|
|
||||||
#define xAsprintf(strp, fmt, ...) do { int _r=asprintf(strp, fmt, __VA_ARGS__); if (_r < 0) { fail(); } } while(0)
|
ATTR_FORMAT(printf, 3, 4)
|
||||||
|
int xSnprintf(char *buf, int len, const char* fmt, ...);
|
||||||
|
|
||||||
#define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0)
|
char* xStrdup(const char* str) ATTR_NONNULL;
|
||||||
|
|
||||||
#undef xStrdup
|
|
||||||
#undef xStrdup_
|
|
||||||
#ifdef NDEBUG
|
|
||||||
# define xStrdup_ xStrdup
|
|
||||||
#else
|
|
||||||
# define xStrdup(str_) (assert(str_), xStrdup_(str_))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char* xStrdup_(const char* str) ATTR_NONNULL;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
19
configure.ac
19
configure.ac
|
@ -169,6 +169,23 @@ m4_define([HTOP_CHECK_LIB],
|
||||||
], [$4])
|
], [$4])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
||||||
|
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||||
|
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||||
|
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||||
|
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||||
|
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||||
|
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
||||||
|
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||||
|
[AS_VAR_SET(CACHEVAR,[no])])
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||||
|
AS_VAR_IF(CACHEVAR,yes,
|
||||||
|
[m4_default([$2], :)],
|
||||||
|
[m4_default([$3], :)])
|
||||||
|
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||||
|
])dnl AX_CHECK_COMPILE_FLAGS
|
||||||
|
|
||||||
AC_ARG_ENABLE(unicode, [AS_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
|
AC_ARG_ENABLE(unicode, [AS_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
|
||||||
if test "x$enable_unicode" = xyes; then
|
if test "x$enable_unicode" = xyes; then
|
||||||
HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
|
HTOP_CHECK_SCRIPT([ncursesw6], [addnwstr], [HAVE_LIBNCURSESW], "ncursesw6-config",
|
||||||
|
@ -291,6 +308,8 @@ AM_CFLAGS="\
|
||||||
-Wunused\
|
-Wunused\
|
||||||
-Wwrite-strings"
|
-Wwrite-strings"
|
||||||
|
|
||||||
|
AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
|
||||||
|
|
||||||
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no])
|
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no])
|
||||||
AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"])
|
AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue