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

@@ -172,12 +172,12 @@ virTestLoadFile(const char *file, char **buf)
int len, tmplen, buflen;
if (!fp) {
fprintf(stderr, "%s: failed to open: %s\n", file, strerror(errno));
fprintf(stderr, "%s: failed to open: %s\n", file, g_strerror(errno));
return -1;
}
if (fstat(fileno(fp), &st) < 0) {
fprintf(stderr, "%s: failed to fstat: %s\n", file, strerror(errno));
fprintf(stderr, "%s: failed to fstat: %s\n", file, g_strerror(errno));
VIR_FORCE_FCLOSE(fp);
return -1;
}
@@ -208,7 +208,7 @@ virTestLoadFile(const char *file, char **buf)
tmplen -= len;
}
if (ferror(fp)) {
fprintf(stderr, "%s: read failed: %s\n", file, strerror(errno));
fprintf(stderr, "%s: read failed: %s\n", file, g_strerror(errno));
VIR_FORCE_FCLOSE(fp);
VIR_FREE(*buf);
return -1;