]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: make path_set_prefix() independent on cpu_set_t
authorKarel Zak <kzak@redhat.com>
Mon, 23 Oct 2017 13:45:01 +0000 (15:45 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Oct 2017 13:45:01 +0000 (15:45 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/path.h
lib/path.c

index ae36d7f4c91baefc4f35330f3513dd0fb3b67d3a..4be01095cd778aca265ad16a064f7f37f8ebbd9c 100644 (file)
@@ -6,6 +6,10 @@
 
 /* Returns a pointer to a static buffer which may be destroyed by any later
 path_* function call. NULL means error and errno will be set. */
+/* Returns: 0 on success, sets errno on error. */
+extern int path_set_prefix(const char *)
+                       __attribute__((warn_unused_result));
+
 extern const char *path_get(const char *path, ...)
                        __attribute__ ((__format__ (__printf__, 1, 2)));
 
@@ -31,10 +35,5 @@ extern cpu_set_t *path_read_cpuset(int, const char *path, ...)
 extern cpu_set_t *path_read_cpulist(int, const char *path, ...)
                               __attribute__ ((__format__ (__printf__, 2, 3)));
 
-/* Returns: 0 on success, sets errno on error. */
-extern int path_set_prefix(const char *)
-                       __attribute__((warn_unused_result));
-
 #endif /* HAVE_CPU_SET_T */
-
 #endif /* UTIL_LINUX_PATH_H */
index 79c1e7a6816a1e92a36082d0ab6d63f3af4f2dab..e8cfa557afec06bb3a5540bbd690999463355ab5 100644 (file)
 static size_t prefixlen;
 static char pathbuf[PATH_MAX];
 
+int
+path_set_prefix(const char *prefix)
+{
+       size_t len = strlen(prefix);
+
+       if (len >= sizeof(pathbuf) - 1) {
+               errno = ENAMETOOLONG;
+               return -1;
+       }
+       prefixlen = len;
+       strcpy(pathbuf, prefix);
+       return 0;
+}
+
 static const char *
 path_vcreate(const char *path, va_list ap)
 {
@@ -259,19 +273,4 @@ path_read_cpulist(int maxcpus, const char *path, ...)
 
        return set;
 }
-
-int
-path_set_prefix(const char *prefix)
-{
-       size_t len = strlen(prefix);
-
-       if (len >= sizeof(pathbuf) - 1) {
-               errno = ENAMETOOLONG;
-               return -1;
-       }
-       prefixlen = len;
-       strcpy(pathbuf, prefix);
-       return 0;
-}
-
 #endif /* HAVE_CPU_SET_T */