openvz: Handle getline failures in openvzReadConfigParam properly

The regression fix in 3aab7f2d6b altered the error handling.
getline returns -1 on failure to read a line (including EOF). The
original openvzReadConfigParam function using openvz_readline only
treated EOF as not-found. The current getline version treats all
getline failures as not-found.

This patch fixes this and distinguishes EOF from other getline
failures.
This commit is contained in:
Matthias Bolte 2011-05-27 12:35:50 +02:00
parent ad962bcdaa
commit 4b15aad0d6

View File

@ -659,7 +659,12 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
return -1;
VIR_FREE(*value);
while (getline(&line, &line_size, fp) >= 0) {
while (1) {
if (getline(&line, &line_size, fp) < 0) {
err = !feof(fp);
break;
}
if (! STREQLEN(line, param, strlen(param)))
continue;