From 0f99d49ae680e675809428deace3c4fe839d323c Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 24 Jul 2008 23:38:04 +0000 Subject: *: conversion to config parser function old new delta config_read 540 597 +57 config_open2 41 44 +3 rtnl_rtprot_initialize 70 66 -4 rtnl_rttable_initialize 78 73 -5 rtnl_rtscope_initialize 88 83 -5 rtnl_rtrealm_initialize 48 43 -5 rtnl_rtdsfield_initialize 48 43 -5 process_module 566 560 -6 bbunpack 391 383 -8 rtnl_tab_initialize 279 121 -158 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/8 up/down: 60/-196) Total: -136 bytes --- modutils/modprobe-small.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'modutils') diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index f75dae8..1654cc5 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -485,23 +485,19 @@ static module_info* find_alias(const char *alias) } #if ENABLE_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED +// TODO: open only once, invent config_rewind() static int already_loaded(const char *name) { int ret = 0; - int len = strlen(name); - char *line; - FILE* modules; - - modules = xfopen_for_read("/proc/modules"); - while ((line = xmalloc_fgets(modules)) != NULL) { - if (strncmp(line, name, len) == 0 && line[len] == ' ') { - free(line); + char *s; + parser_t *parser = config_open2("/proc/modules", xfopen_for_read); + while (config_read(parser, &s, 1, 1, "# \t", 0)) { + if (strcmp(s, name) == 0) { ret = 1; break; } - free(line); } - fclose(modules); + config_close(parser); return ret; } #else -- cgit v1.1