mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user