{ }
};
-inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
-{
- size_t s;
-
- for (s = 0; s < PATH_MAX - 1; s++) {
- const char c = alias[s];
- switch (c) {
- case '-':
- buf[s] = '_';
- break;
- case ']':
- return -EINVAL;
- case '[':
- while (alias[s] != ']' && alias[s] != '\0') {
- buf[s] = alias[s];
- s++;
- }
-
- if (alias[s] != ']')
- return -EINVAL;
-
- buf[s] = alias[s];
- break;
- case '\0':
- goto finish;
- default:
- buf[s] = c;
- }
- }
-
-finish:
- buf[s] = '\0';
-
- if (len)
- *len = s;
-
- return 0;
-}
-
inline char *modname_normalize(const char *modname, char buf[PATH_MAX],
size_t *len)
{
#define KMOD_EXTENSION_UNCOMPRESSED ".ko"
-int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) _must_check_ __attribute__((nonnull(1,2)));
char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2)));
char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2)));
bool path_ends_with_kmod_ext(const char *path, size_t len) __attribute__((nonnull(1)));
return s;
}
+/* module-related functions */
+/* ************************************************************************ */
+int alias_normalize(const char *alias, char buf[static PATH_MAX], size_t *len)
+{
+ size_t i;
+
+ for (i = 0; i < PATH_MAX - 1; i++) {
+ const char c = alias[i];
+ switch (c) {
+ case '-':
+ buf[i] = '_';
+ break;
+ case ']':
+ return -EINVAL;
+ case '[':
+ while (alias[i] != ']' && alias[i] != '\0') {
+ buf[i] = alias[i];
+ i++;
+ }
+
+ if (alias[i] != ']')
+ return -EINVAL;
+
+ buf[i] = alias[i];
+ break;
+ case '\0':
+ goto finish;
+ default:
+ buf[i] = c;
+ }
+ }
+
+finish:
+ buf[i] = '\0';
+ if (len)
+ *len = i;
+
+ return 0;
+}
+
/* read-like and fread-like functions */
/* ************************************************************************ */
ssize_t read_str_safe(int fd, char *buf, size_t buflen)
char *strchr_replace(char *s, int c, char r);
void *memdup(const void *p, size_t n) __attribute__((nonnull(1)));
+/* module-related functions */
+/* ************************************************************************ */
+int alias_normalize(const char *alias, char buf[static PATH_MAX], size_t *len) _must_check_ __attribute__((nonnull(1,2)));
+
/* read-like and fread-like functions */
/* ************************************************************************ */
ssize_t read_str_safe(int fd, char *buf, size_t buflen) _must_check_ __attribute__((nonnull(2)));
#include <shared/util.h>
-#include <libkmod.h>
-#include <libkmod-util.h>
-
#include "testsuite.h"
static int alias_1(const struct test *t)