Hi Michal,
Thanks for your reply.
On 7/15/21 8:18 AM, Yi Wang wrote:
> From: Long YunJian <long.yunjian(a)zte.com.cn>
>
> If fscanf execute failed, qemuGetProcessInfo shuld return -1,
> but it return 0 at the end. Zero means success for the caller,
> so we shuld return -1 in the case of failure.
>
...
> /* cutime -> endcode */
> @@ -1455,6 +1457,8 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu,
long *vm_rss,
> "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d",
> &usertime, &systime, &rss, &cpu) != 4) {
> VIR_WARN("cannot parse process status data");
> + VIR_FORCE_FCLOSE(pidinfo);
> + return -1;
There's another VIR_FORCE_FCLOSE() at the end of the function. It should
be removed.
VIR_FORCE_FCLOSE() at the end of the function means in the
situation of success, but VIR_FORCE_FCLOSE before return -1 is
failure situation. if removed, it will result in not close pidinfo.
But is there an actual error you're seeing? Has /proc/NNN/stat format
changed? Also, please use git send-email if possible - it allows
reviewers to use git am (which doesn't work with multipart e-mails).
I haven't meet fscanf return error, but in some abnormal situation,
such as interrupted by a signal or out of memory, it may return failure.
Actually I used git send-email to send this patch, if there's something
wrong, please let me know and I will forward that to our IT department :)
Michal