util: replace strerror/strerror_r with g_strerror

g_strerror is offers the safety/correctness benefits of strerror_r, with
the API design convenience of strerror.

Use of virStrerror should be eliminated through the codebase in favour
of g_strerror.

commandhelper.c is a special case as its a tiny single threaded test
program, not linked to glib, so it just uses traditional strerror().

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2019-10-02 16:30:36 +01:00
parent 71efb59a4d
commit c4d18e8b3e
10 changed files with 25 additions and 21 deletions

View File

@@ -37,7 +37,7 @@ linuxTestCompareFiles(const char *cpuinfofile,
cpuinfo = fopen(cpuinfofile, "r");
if (!cpuinfo) {
fprintf(stderr, "unable to open: %s : %s\n",
cpuinfofile, strerror(errno));
cpuinfofile, g_strerror(errno));
goto fail;
}
@@ -86,7 +86,7 @@ linuxCPUStatsToBuf(virBufferPtr buf,
if ((sc_clk_tck = sysconf(_SC_CLK_TCK)) < 0) {
fprintf(stderr, "sysconf(_SC_CLK_TCK) fails : %s\n",
strerror(errno));
g_strerror(errno));
return -1;
}
tick_to_nsec = (1000ull * 1000ull * 1000ull) / sc_clk_tck;