]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
coding style: be consistent with blank lines
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Mon, 12 Dec 2011 13:52:59 +0000 (11:52 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Mon, 12 Dec 2011 13:52:59 +0000 (11:52 -0200)
libkmod/libkmod-config.c
libkmod/libkmod-module.c
libkmod/libkmod-util.c

index 2b3222dd76da4fa9bfeb964ebcd7d7c76bcd76da..c98bab938961a6bbc46d65e2767c48c45ed5b6ad 100644 (file)
@@ -179,6 +179,7 @@ static int kmod_config_add_alias(struct kmod_config *config,
        alias = malloc(sizeof(*alias) + namelen + modnamelen);
        if (!alias)
                goto oom_error_init;
+
        alias->name = sizeof(*alias) + modnamelen + (char *)alias;
 
        memcpy(alias->modname, modname, modnamelen);
@@ -187,6 +188,7 @@ static int kmod_config_add_alias(struct kmod_config *config,
        list = kmod_list_append(config->aliases, alias);
        if (!list)
                goto oom_error;
+
        config->aliases = list;
        return 0;
 
index ce01dc3314476d3b03f8cba64a11452a40d4c515..500193d022181c66d9b950ab8f32aa9d87437e19 100644 (file)
@@ -74,6 +74,7 @@ inline char *modname_normalize(const char *modname, char buf[NAME_MAX],
                else
                        buf[s] = c;
        }
+
        buf[s] = '\0';
 
        if (len)
@@ -133,6 +134,7 @@ int kmod_module_parse_depline(struct kmod_module *mod, char *line)
        dirnamelen = strlen(dirname);
        if (dirnamelen + 2 >= PATH_MAX)
                return 0;
+
        memcpy(buf, dirname, dirnamelen);
        buf[dirnamelen] = '/';
        dirnamelen++;
@@ -410,6 +412,7 @@ KMOD_EXPORT struct kmod_module *kmod_module_get_module(const struct kmod_list *e
 {
        if (entry == NULL)
                return NULL;
+
        return kmod_module_ref(entry->data);
 }
 
@@ -730,6 +733,7 @@ KMOD_EXPORT struct kmod_list *kmod_module_get_sections(const struct kmod_module
 
        if (mod == NULL)
                return NULL;
+
        snprintf(dname, sizeof(dname), "/sys/module/%s/sections", mod->name);
 
        d = opendir(dname);
@@ -771,7 +775,6 @@ KMOD_EXPORT struct kmod_list *kmod_module_get_sections(const struct kmod_module
 
                err = read_str_ulong(fd, &address, 16);
                close(fd);
-
                if (err < 0) {
                        ERR(mod->ctx, "could not read long from '%s/%s': %m\n",
                                                        dname, de.d_name);
@@ -811,8 +814,10 @@ fail:
 KMOD_EXPORT const char *kmod_module_section_get_name(const struct kmod_list *entry)
 {
        struct kmod_module_section *section;
+
        if (entry == NULL)
                return NULL;
+
        section = entry->data;
        return section->name;
 }
@@ -820,8 +825,10 @@ KMOD_EXPORT const char *kmod_module_section_get_name(const struct kmod_list *ent
 KMOD_EXPORT unsigned long kmod_module_section_get_address(const struct kmod_list *entry)
 {
        struct kmod_module_section *section;
+
        if (entry == NULL)
                return (unsigned long)-1;
+
        section = entry->data;
        return section->address;
 }
@@ -845,7 +852,9 @@ KMOD_EXPORT const char *kmod_module_get_options(const struct kmod_module *mod)
                const struct kmod_list *l, *ctx_options;
                char *opts = NULL;
                size_t optslen = 0;
+
                ctx_options = kmod_get_options(mod->ctx);
+
                kmod_list_foreach(l, ctx_options) {
                        const char *modname = kmod_option_get_modname(l);
                        const char *str;
@@ -865,15 +874,19 @@ KMOD_EXPORT const char *kmod_module_get_options(const struct kmod_module *mod)
                                free(opts);
                                goto failed;
                        }
+
                        opts = tmp;
+
                        if (optslen > 0) {
                                opts[optslen] = ' ';
                                optslen++;
                        }
+
                        memcpy(opts + optslen, str, len);
                        optslen += len;
                        opts[optslen] = '\0';
                }
+
                m->init.options = true;
                m->options = opts;
        }
@@ -896,7 +909,9 @@ KMOD_EXPORT const char *kmod_module_get_install_commands(const struct kmod_modul
                const struct kmod_list *l, *ctx_install_commands;
                char *cmds = NULL;
                size_t cmdslen = 0;
+
                ctx_install_commands = kmod_get_install_commands(mod->ctx);
+
                kmod_list_foreach(l, ctx_install_commands) {
                        const char *modname = kmod_command_get_modname(l);
                        const char *str;
@@ -916,15 +931,19 @@ KMOD_EXPORT const char *kmod_module_get_install_commands(const struct kmod_modul
                                free(cmds);
                                goto failed;
                        }
+
                        cmds = tmp;
+
                        if (cmdslen > 0) {
                                cmds[cmdslen] = ';';
                                cmdslen++;
                        }
+
                        memcpy(cmds + cmdslen, str, len);
                        cmdslen += len;
                        cmds[cmdslen] = '\0';
                }
+
                m->init.install_commands = true;
                m->install_commands = cmds;
        }
@@ -947,7 +966,9 @@ KMOD_EXPORT const char *kmod_module_get_remove_commands(const struct kmod_module
                const struct kmod_list *l, *ctx_remove_commands;
                char *cmds = NULL;
                size_t cmdslen = 0;
+
                ctx_remove_commands = kmod_get_remove_commands(mod->ctx);
+
                kmod_list_foreach(l, ctx_remove_commands) {
                        const char *modname = kmod_command_get_modname(l);
                        const char *str;
@@ -967,15 +988,19 @@ KMOD_EXPORT const char *kmod_module_get_remove_commands(const struct kmod_module
                                free(cmds);
                                goto failed;
                        }
+
                        cmds = tmp;
+
                        if (cmdslen > 0) {
                                cmds[cmdslen] = ';';
                                cmdslen++;
                        }
+
                        memcpy(cmds + cmdslen, str, len);
                        cmdslen += len;
                        cmds[cmdslen] = '\0';
                }
+
                m->init.remove_commands = true;
                m->remove_commands = cmds;
        }
index 9a68a3e236c154d12391b2382b23aa71ef2b4481..40b7adaa6741addb65062a8a73e0d3d75515a52b 100644 (file)
@@ -45,6 +45,7 @@ char *getline_wrapped(FILE *fp, unsigned int *linenum)
        int size = 256;
        int i = 0;
        char *buf = malloc(size);
+
        for(;;) {
                int ch = getc_unlocked(fp);
 
@@ -147,8 +148,10 @@ inline void *memdup(const void *p, size_t n)
 ssize_t read_str_safe(int fd, char *buf, size_t buflen) {
        size_t todo = buflen;
        size_t done;
+
        do {
                ssize_t r = read(fd, buf, todo);
+
                if (r == 0)
                        break;
                else if (r > 0)
@@ -161,7 +164,9 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen) {
                                return -errno;
                }
        } while (todo > 0);
+
        done = buflen - todo;
+
        if (done == 0)
                buf[0] = '\0';
        else {
@@ -170,6 +175,7 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen) {
                else if (buf[done - 1] != '\0')
                        return -ENOSPC;
        }
+
        return done;
 }
 
@@ -177,6 +183,7 @@ int read_str_long(int fd, long *value, int base) {
        char buf[32], *end;
        long v;
        int err;
+
        *value = 0;
        err = read_str_safe(fd, buf, sizeof(buf));
        if (err < 0)
@@ -185,6 +192,7 @@ int read_str_long(int fd, long *value, int base) {
        v = strtol(buf, &end, base);
        if (end == buf || !isspace(*end))
                return -EINVAL;
+
        *value = v;
        return 0;
 }
@@ -193,6 +201,7 @@ int read_str_ulong(int fd, unsigned long *value, int base) {
        char buf[32], *end;
        long v;
        int err;
+
        *value = 0;
        err = read_str_safe(fd, buf, sizeof(buf));
        if (err < 0)
@@ -208,9 +217,11 @@ int read_str_ulong(int fd, unsigned long *value, int base) {
 char *strchr_replace(char *s, int c, char r)
 {
        char *p;
+
        for (p = s; *p != '\0'; p++)
                if (*p == c)
                        *p = r;
+
        return s;
 }