diff options
| author | Thomas Haller <thaller@redhat.com> | 2016-05-24 15:57:16 +0200 |
|---|---|---|
| committer | Thomas Haller <thaller@redhat.com> | 2016-05-24 16:01:59 +0200 |
| commit | d7b4733d3ea39964c0918da29d6ece6030a81bce (patch) | |
| tree | 89bb1702ff7bfcd43c10bb616355638323073f3a | |
| parent | 487dcf7e550a1263af722ace8f4577f8f048d885 (diff) | |
| download | NetworkManager-d7b4733d3ea39964c0918da29d6ece6030a81bce.tar.gz | |
ifcfg-rh: avoid creating temporary string prefix for svGetValueFull()
| -rw-r--r-- | src/settings/plugins/ifcfg-rh/shvar.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 9931c79cf1..75b19d5383 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -271,26 +271,23 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) { char *value = NULL; char *line; - char *keyString; - int len; + guint len; g_return_val_if_fail (s != NULL, NULL); g_return_val_if_fail (key != NULL, NULL); - keyString = g_strdup_printf ("%s=", key); - len = strlen (keyString); + len = strlen (key); for (s->current = s->lineList; s->current; s->current = s->current->next) { line = s->current->data; - if (!strncmp (keyString, line, len)) { + if (!strncmp (key, line, len) && line[len] == '=') { /* Strip trailing spaces before unescaping to preserve spaces quoted whitespace */ - value = g_strchomp (g_strdup (line + len)); + value = g_strchomp (g_strdup (line + len + 1)); if (!verbatim) svUnescape (value); break; } } - g_free (keyString); return value; } |
