From 8e92264b4ec3e67440da89ff6602320758840ffd Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 27 Dec 2012 23:23:23 +0100 Subject: build: switch to C99 Remove some redundant checks while at it. --- configure.ac | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index b1f6363283..bc863b3cd1 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,11 @@ AC_PROG_SED AC_PROG_GREP AC_PROG_AWK -AC_PROG_CC +AC_PROG_CC_C99 +AS_IF([test "x$ac_cv_prog_cc_c99" = "xno"], [ + AC_MSG_ERROR([no C99 compiler found, $PACKAGE requires a C99 compiler.]) +]) + AC_PROG_CXX AC_PROG_CPP AC_PROG_INSTALL @@ -41,8 +45,8 @@ PKG_CHECK_MODULES(BLKID,[blkid >= 2.20]) # Checks for header files. AC_CHECK_HEADERS( - [arpa/inet.h fcntl.h inttypes.h langinfo.h limits.h locale.h malloc.h \ - netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/mount.h \ + [arpa/inet.h fcntl.h inttypes.h langinfo.h limits.h locale.h \ + netinet/in.h sys/ioctl.h sys/mount.h \ sys/param.h sys/socket.h sys/statvfs.h sys/time.h sys/vfs.h syslog.h \ termios.h unistd.h], [], @@ -50,21 +54,11 @@ AC_CHECK_HEADERS( ) # Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL AC_TYPE_UID_T AC_C_INLINE -AC_TYPE_INT32_T -AC_TYPE_INT64_T AC_TYPE_MODE_T -AC_TYPE_OFF_T AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_TYPE_SSIZE_T AC_CHECK_MEMBERS([struct stat.st_rdev]) -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T -AC_TYPE_UINT8_T AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, accept4], [], [], [[#include #include #include @@ -73,25 +67,19 @@ AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, accept4], [], [], [[#incl # Checks for library functions. -AC_FUNC_ALLOCA AC_FUNC_CHOWN AC_FUNC_FORK AC_FUNC_FSEEKO AC_FUNC_GETGROUPS AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_HEADER_MAJOR -AC_FUNC_MALLOC AC_FUNC_MKTIME AC_FUNC_MMAP -AC_FUNC_REALLOC -AC_FUNC_STRNLEN -AC_FUNC_STRTOD AC_CHECK_FUNCS( - [alarm dup2 ftruncate localtime_r memchr memmove mempcpy memset \ - mkdir munmap nl_langinfo rmdir setlocale socket stpcpy strcasecmp \ - strchr strcspn strdup strerror strndup strpbrk strrchr strspn \ - strstr strtol strtoul strtoull uname], + [alarm dup2 ftruncate localtime_r mempcpy \ + mkdir munmap nl_langinfo rmdir setlocale socket stpcpy \ + uname], [], [AC_MSG_ERROR([*** POSIX function not found])] ) -- cgit v1.2.3-54-g00ecf From bdd4de160c6b1252396db4b6531aa8c71e5b0698 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 27 Dec 2012 23:27:06 +0100 Subject: cgroup: factorize path Spare few bytes and make typos less likely. --- src/libudev/cgroup-util.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libudev/cgroup-util.c b/src/libudev/cgroup-util.c index b0d378de5a..19f9889c8a 100644 --- a/src/libudev/cgroup-util.c +++ b/src/libudev/cgroup-util.c @@ -37,6 +37,8 @@ #include "path-util.h" #include "strv.h" +static const char cgroup_path[] = "/sys/fs/cgroup/"; + int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) { char *fs; int r; @@ -522,13 +524,13 @@ static int join_path(const char *controller, const char *path, const char *suffi if (controller) { if (path && suffix) - t = strjoin("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL); + t = strjoin(cgroup_path, controller, "/", path, "/", suffix, NULL); else if (path) - t = strjoin("/sys/fs/cgroup/", controller, "/", path, NULL); + t = strjoin(cgroup_path, controller, "/", path, NULL); else if (suffix) - t = strjoin("/sys/fs/cgroup/", controller, "/", suffix, NULL); + t = strjoin(cgroup_path, controller, "/", suffix, NULL); else - t = strjoin("/sys/fs/cgroup/", controller, NULL); + t = strjoin(cgroup_path, controller, NULL); } else { if (path && suffix) t = strjoin(path, "/", suffix, NULL); @@ -572,8 +574,8 @@ static int check(const char *p) { assert(p); /* Check if this controller actually really exists */ - cc = alloca(sizeof("/sys/fs/cgroup/") + strlen(p)); - strcpy(stpcpy(cc, "/sys/fs/cgroup/"), p); + cc = alloca(sizeof(cgroup_path) + strlen(p)); + strcpy(stpcpy(cc, cgroup_path), p); if (access(cc, F_OK) < 0) return -errno; -- cgit v1.2.3-54-g00ecf