Hi, I found that some codes use "%m" and some other code use "%s + strerror(errno)" to show error message. so I clean up the whole code to use "%m" instead of "%s + strerror(errno)". this patch is not bug fix or enhancement, but I feel it is better to use one rule in whole code. I'd appreciate it if you could review this attached patch. thank you,
diff --git a/isys/eddsupport.c b/isys/eddsupport.c index 230bf06..55b958d 100644 --- a/isys/eddsupport.c +++ b/isys/eddsupport.c @@ -110,8 +110,7 @@ static int readDiskSig(char *device, uint32_t *disksig) { fd = open("/tmp/biosdev", O_RDONLY); if (fd < 0) { #ifdef STANDALONE - fprintf(stderr, "Error opening device %s: %s\n ", device, - strerror(errno)); + fprintf(stderr, "Error opening device %s: %m\n ", device); #endif return -errno; } @@ -121,8 +120,8 @@ static int readDiskSig(char *device, uint32_t *disksig) { close(fd); #ifdef STANDALONE - fprintf(stderr, "Error seeking to MBRSIG_OFFSET in %s: %s\n", - device, strerror(errno)); + fprintf(stderr, "Error seeking to MBRSIG_OFFSET in %s: %m\n", + device); #endif return -1; } @@ -153,8 +152,7 @@ static int mapBiosDisks(struct device** devices,const char *path) { dirHandle = opendir(path); if(!dirHandle){ #ifdef STANDALONE - fprintf(stderr, "Failed to open directory %s: %s\n", path, - strerror(errno)); + fprintf(stderr, "Failed to open directory %s: %m\n", path); #endif return 0; } @@ -216,8 +214,7 @@ static int readMbrSig(char *filename, uint32_t *int_sig){ fh = fopen(filename,"r"); if(fh == NULL) { #ifdef STANDALONE - fprintf(stderr, "Error opening mbr_signature file %s: %s\n", filename, - strerror(errno)); + fprintf(stderr, "Error opening mbr_signature file %s: %m\n", filename); #endif return -1; } diff --git a/isys/ethtool.c b/isys/ethtool.c index e1e68c7..e2b049f 100644 --- a/isys/ethtool.c +++ b/isys/ethtool.c @@ -33,8 +33,7 @@ static int set_intf_up(struct ifreq ifr, int sock) { } ifr.ifr_flags |= (IFF_UP | IFF_RUNNING); if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) { - fprintf(stderr, "failed to bring up interface %s: %s", ifr.ifr_name, - strerror(errno)); + fprintf(stderr, "failed to bring up interface %s: %m", ifr.ifr_name); return -1; } return (0); @@ -56,8 +55,7 @@ int setEthtoolSettings(char * dev, ethtool_speed speed, strcpy(ifr.ifr_name, dev); if (set_intf_up(ifr, sock) == -1) { - fprintf(stderr, "unable to bring up interface %s: %s", dev, - strerror(errno)); + fprintf(stderr, "unable to bring up interface %s: %m", dev); return -1; } diff --git a/isys/linkdetect.c b/isys/linkdetect.c index 1d1e33e..73356e9 100644 --- a/isys/linkdetect.c +++ b/isys/linkdetect.c @@ -43,8 +43,7 @@ static int mdio_read(int skfd, int location) mii->reg_num = location; if (ioctl(skfd, SIOCGMIIREG, &ifr) < 0) { #ifdef STANDALONE - fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); + fprintf(stderr, "SIOCGMIIREG on %s failed: %m\n", ifr.ifr_name); #endif return -1; } @@ -75,8 +74,8 @@ static int get_mii_link_status(int sock) { if (ioctl(sock, SIOCGMIIPHY, &ifr) < 0) { if (errno != ENODEV) #ifdef STANDALONE - fprintf(stderr, "SIOCGMIIPHY on '%s' failed: %s\n", - ifr.ifr_name, strerror(errno)); + fprintf(stderr, "SIOCGMIIPHY on '%s' failed: %m\n", + ifr.ifr_name); #endif return -1; } @@ -111,7 +110,7 @@ static int get_ethtool_link_status(int sock) { return edata.data; } else if (errno != EOPNOTSUPP) { #ifdef STANDALONE - fprintf(stderr, "Cannot get link status (%d): %s\n", errno, strerror(errno)); + fprintf(stderr, "Cannot get link status (%d): %m\n", errno); #endif } @@ -125,7 +124,7 @@ int get_link_status(char * devname) { if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { #ifdef STANDALONE - fprintf(stderr, "Error creating socket: %s\n", strerror(errno)); + fprintf(stderr, "Error creating socket: %m\n"); #endif return -1; } diff --git a/isys/wireless.c b/isys/wireless.c index c19da01..7e12bbe 100644 --- a/isys/wireless.c +++ b/isys/wireless.c @@ -43,7 +43,7 @@ static int get_socket() { if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { #ifdef STANDALONE - fprintf(stderr, "Error creating socket: %s\n", strerror(errno)); + fprintf(stderr, "Error creating socket: %m\n"); #endif return -1; } @@ -94,7 +94,7 @@ int set_essid(char * ifname, char * essid) { close(sock); if (rc < 0) { - fprintf(stderr, "failed to set essid: %s\n", strerror(errno)); + fprintf(stderr, "failed to set essid: %m\n"); return -1; } @@ -117,8 +117,7 @@ char * get_essid(char * ifname) { close(sock); if (rc < 0) { - fprintf(stderr, "failed to get essid for %s: %s\n", ifname, - strerror(errno)); + fprintf(stderr, "failed to get essid for %s: %m\n", ifname); return NULL; } @@ -209,7 +208,7 @@ int set_wep_key(char * ifname, char * key) { close(sock); if (rc < 0) { - fprintf(stderr, "failed to set wep key: %s\n", strerror(errno)); + fprintf(stderr, "failed to set wep key: %m\n"); return -1; } @@ -228,7 +227,7 @@ int set_managed(char * ifname) { close(sock); if (rc < 0) { - fprintf(stderr, "failed to set managed mode: %s\n", strerror(errno)); + fprintf(stderr, "failed to set managed mode: %m\n"); return -1; } diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c index a4c7eed..638c711 100644 --- a/loader2/cdinstall.c +++ b/loader2/cdinstall.c @@ -188,7 +188,7 @@ static int getISOStatusFromCDROM(char *cddriver, char *mediasum) { devMakeInode(cddriver, "/tmp/cdrom"); isofd = open("/tmp/cdrom", O_RDONLY); if (isofd < 0) { - logMessage(WARNING, "Could not check iso status: %s", strerror(errno)); + logMessage(WARNING, "Could not check iso status: %m"); unlink("/tmp/cdrom"); return 0; } diff --git a/loader2/copy.c b/loader2/copy.c index 25625f6..2f5793c 100644 --- a/loader2/copy.c +++ b/loader2/copy.c @@ -42,8 +42,7 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *), if (!(dir = opendir(from))) { if (errorFn) { - x = asprintf(&msg, N_("Failed to read directory %s: %s"), from, - strerror(errno)); + x = asprintf(&msg, N_("Failed to read directory %s: %m"), from); errorFn(msg); free(msg); } @@ -71,8 +70,8 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *), link[i] = '\0'; if (symlink(link, filespec2)) { if (warnFn) { - x = asprintf(&msg, "Failed to symlink %s to %s: %s", - filespec2, link, strerror(errno)); + x = asprintf(&msg, "Failed to symlink %s to %s: %m", + filespec2, link); warnFn(msg); free(msg); } @@ -81,8 +80,7 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *), fd = open(filespec, O_RDONLY); if (fd == -1) { if (errorFn) { - x = asprintf(&msg, "Failed to open %s: %s", filespec, - strerror(errno)); + x = asprintf(&msg, "Failed to open %s: %m", filespec); errorFn(msg); free(msg); } @@ -93,8 +91,7 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *), outfd = open(filespec2, O_RDWR | O_TRUNC | O_CREAT, 0644); if (outfd == -1) { if (warnFn) { - x = asprintf(&msg, "Failed to create %s: %s", filespec2, - strerror(errno)); + x = asprintf(&msg, "Failed to create %s: %m", filespec2); warnFn(msg); free(msg); } diff --git a/loader2/dirbrowser.c b/loader2/dirbrowser.c index 6ebaa43..c8775cd 100644 --- a/loader2/dirbrowser.c +++ b/loader2/dirbrowser.c @@ -70,7 +70,7 @@ static char ** get_file_list(char * dirname, dir = opendir(dirname); if (dir == NULL) { - fprintf(stderr, "error opening %s: %s", dirname, strerror(errno)); + fprintf(stderr, "error opening %s: %m", dirname); return NULL; } diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c index 6cbf801..16a25f0 100644 --- a/loader2/driverdisk.c +++ b/loader2/driverdisk.c @@ -334,7 +334,7 @@ int loadDriverFromMedia(int class, struct loaderData_s *loaderData, /* make sure nothing is mounted when we get here */ num = umount("/tmp/dpart"); if (num == -1) { - logMessage(ERROR, "error unmounting: %s", strerror(errno)); + logMessage(ERROR, "error unmounting: %m"); if ((errno != EINVAL) && (errno != ENOENT)) exit(1); } diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 71276c0..72c3848 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -82,18 +82,18 @@ static int loadHDImages(char * prefix, char * dir, logMessage(INFO, "Looking for hd stage2 image %s", path); if (!access(path, F_OK)) break; - logMessage(INFO, "%s does not exist: %s, trying next target", path, strerror(errno)); + logMessage(INFO, "%s does not exist: %m, trying next target", path); } if (!target) { - logMessage(ERROR, "failed to find hd stage 2 image%s: %s", path, strerror(errno)); + logMessage(ERROR, "failed to find hd stage 2 image%s: %m", path); return 1; } logMessage(INFO, "Found hd stage2, copying %s in RAM as stage2", path); if ((fd = open(path, O_RDONLY)) < 0) { - logMessage(ERROR, "failed to open %s: %s", path, strerror(errno)); + logMessage(ERROR, "failed to open %s: %m", path); return 1; } } diff --git a/loader2/init.c b/loader2/init.c index d654d4c..5f145a2 100644 --- a/loader2/init.c +++ b/loader2/init.c @@ -388,8 +388,8 @@ static void createDevices(void) { switch (devnodes[i].type) { case DIRTYPE: if (mkdir(devname, devnodes[i].perms) < 0) { - fprintf(stderr, "Unable to create directory %s: %s\n", - devname, strerror(errno)); + fprintf(stderr, "Unable to create directory %s: %m\n", + devname); } break; case CHARDEV: @@ -403,8 +403,7 @@ static void createDevices(void) { if (mknod(devname, type | devnodes[i].perms, makedev(devnodes[i].major, devnodes[i].minor)) < 0) - fprintf(stderr, "Unable to create device %s: %s\n", devname, - strerror(errno)); + fprintf(stderr, "Unable to create device %s: %m\n", devname); } } @@ -728,7 +727,7 @@ int main(int argc, char **argv) { close(fd); free(buf); } else { - printf("unable to write init.pid (%d): %s\n", errno, strerror(errno)); + printf("unable to write init.pid (%d): %m\n", errno); sleep(2); } diff --git a/loader2/kbd.c b/loader2/kbd.c index 518c55e..5627d73 100644 --- a/loader2/kbd.c +++ b/loader2/kbd.c @@ -93,12 +93,12 @@ int chooseKeyboard(struct loaderData_s * loaderData, char ** kbdtypep) { f = gunzip_open("/etc/keymaps.gz"); if (!f) { - errorWindow("cannot open /etc/keymaps.gz: %s"); + errorWindow("cannot open /etc/keymaps.gz: %m"); return LOADER_ERROR; } if (gunzip_read(f, &hdr, sizeof(hdr)) != sizeof(hdr)) { - errorWindow("failed to read keymaps header: %s"); + errorWindow("failed to read keymaps header: %m"); gunzip_close(f); return LOADER_ERROR; } @@ -108,7 +108,7 @@ int chooseKeyboard(struct loaderData_s * loaderData, char ** kbdtypep) { i = hdr.numEntries * sizeof(*infoTable); infoTable = alloca(i); if (gunzip_read(f, infoTable, i) != i) { - errorWindow("failed to read keymap information: %s"); + errorWindow("failed to read keymap information: %m"); gunzip_close(f); return LOADER_ERROR; } @@ -141,8 +141,8 @@ int chooseKeyboard(struct loaderData_s * loaderData, char ** kbdtypep) { for (i = 0; i < num; i++) { if (gunzip_read(f, buf, infoTable[i].size) != infoTable[i].size) { - logMessage(ERROR, "error reading %d bytes from file: %s", - infoTable[i].size, strerror(errno)); + logMessage(ERROR, "error reading %d bytes from file: %m", + infoTable[i].size); gunzip_close(f); rc = LOADER_ERROR; } diff --git a/loader2/kickstart.c b/loader2/kickstart.c index d17fcf8..9e3138d 100644 --- a/loader2/kickstart.c +++ b/loader2/kickstart.c @@ -125,8 +125,8 @@ int ksReadCommands(char * cmdFile) { if ((fd = open(cmdFile, O_RDONLY)) < 0) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), - _("Error opening kickstart file %s: %s"), - cmdFile, strerror(errno)); + _("Error opening kickstart file %s: %m"), + cmdFile); return LOADER_ERROR; } @@ -135,8 +135,8 @@ int ksReadCommands(char * cmdFile) { if (read(fd, buf, sb.st_size) != sb.st_size) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), - _("Error reading contents of kickstart file %s: %s"), - cmdFile, strerror(errno)); + _("Error reading contents of kickstart file %s: %m"), + cmdFile); close(fd); return LOADER_ERROR; } diff --git a/loader2/lang.c b/loader2/lang.c index 1532b64..3d2bc90 100644 --- a/loader2/lang.c +++ b/loader2/lang.c @@ -103,8 +103,8 @@ static void loadLanguageList(void) { f = fopen(file, "r"); if (!f) { - newtWinMessage(_("Error"), _("OK"), "cannot open %s: %s", - file, strerror (errno)); + newtWinMessage(_("Error"), _("OK"), "cannot open %s: %m", + file); return; } @@ -178,8 +178,7 @@ void loadLanguage (char * file) { fd = open("/tmp/translation", O_RDONLY); if (fd < 0) { - newtWinMessage("Error", "OK", "Failed to open /tmp/translation: %s\n", - strerror(errno)); + newtWinMessage("Error", "OK", "Failed to open /tmp/translation: %m\n"); return; } diff --git a/loader2/loader.c b/loader2/loader.c index 8f39c65..e92ad71 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -331,7 +331,7 @@ static void spawnShell(void) { setenv("LANG", "C", 1); if (execl("/bin/sh", "-/bin/sh", NULL) == -1) { - logMessage(CRITICAL, "exec of /bin/sh failed: %s", strerror(errno)); + logMessage(CRITICAL, "exec of /bin/sh failed: %m"); exit(1); } } @@ -1727,7 +1727,7 @@ int main(int argc, char ** argv) { * (if we're using SELinux) */ if (FL_SELINUX(flags)) { if (mount("/selinux", "/selinux", "selinuxfs", 0, NULL)) { - logMessage(ERROR, "failed to mount /selinux: %s, disabling SELinux", strerror(errno)); + logMessage(ERROR, "failed to mount /selinux: %m, disabling SELinux"); flags &= ~LOADER_FLAGS_SELINUX; } else { /* FIXME: this is a bad hack for libselinux assuming things @@ -1956,7 +1956,7 @@ int main(int argc, char ** argv) { if (!(pid = fork())) { setenv("ANACONDAVERSION", VERSION, 1); if (execv(anacondaArgs[0], anacondaArgs) == -1) { - fprintf(stderr,"exec of anaconda failed: %s\n",strerror(errno)); + fprintf(stderr,"exec of anaconda failed: %m\n"); exit(1); } } @@ -1974,8 +1974,7 @@ int main(int argc, char ** argv) { char * cmd = (FL_POWEROFF(flags) ? strdup("/sbin/poweroff") : strdup("/sbin/halt")); if (execl(cmd, cmd, NULL) == -1) { - fprintf(stderr, "exec of poweroff failed: %s", - strerror(errno)); + fprintf(stderr, "exec of poweroff failed: %m"); exit(1); } } diff --git a/loader2/loadermisc.c b/loader2/loadermisc.c index 4aae68d..e039788 100644 --- a/loader2/loadermisc.c +++ b/loader2/loadermisc.c @@ -37,7 +37,7 @@ int copyFileFd(int infd, char * dest) { outfd = open(dest, O_CREAT | O_RDWR, 0666); if (outfd < 0) { - logMessage(ERROR, "failed to open %s: %s", dest, strerror(errno)); + logMessage(ERROR, "failed to open %s: %m", dest); return 1; } @@ -60,7 +60,7 @@ int copyFile(char * source, char * dest) { infd = open(source, O_RDONLY); if (infd < 0) { - logMessage(ERROR, "failed to open %s: %s", source, strerror(errno)); + logMessage(ERROR, "failed to open %s: %m", source); return 1; } @@ -196,13 +196,13 @@ int totalMemory(void) { fd = open("/proc/meminfo", O_RDONLY); if (fd < 0) { - logMessage(ERROR, "failed to open /proc/meminfo: %s", strerror(errno)); + logMessage(ERROR, "failed to open /proc/meminfo: %m"); return 0; } bytesRead = read(fd, buf, sizeof(buf) - 1); if (bytesRead < 0) { - logMessage(ERROR, "failed to read from /proc/meminfo: %s", strerror(errno)); + logMessage(ERROR, "failed to read from /proc/meminfo: %m"); close(fd); return 0; } diff --git a/loader2/method.c b/loader2/method.c index 5ed87b8..0e94469 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -63,8 +63,8 @@ int umountLoopback(char * mntpoint, char * device) { loopfd = open("/tmp/loop", O_RDONLY); if (ioctl(loopfd, LOOP_CLR_FD, 0) == -1) - logMessage(ERROR, "LOOP_CLR_FD failed for %s %s (%s)", mntpoint, - device, strerror(errno)); + logMessage(ERROR, "LOOP_CLR_FD failed for %s %s (%m)", mntpoint, + device); close(loopfd); @@ -106,7 +106,7 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) { device, mntpoint, fsystem, loopfd); if (ioctl(loopfd, LOOP_SET_FD, targfd)) { - logMessage(ERROR, "LOOP_SET_FD failed: %s", strerror(errno)); + logMessage(ERROR, "LOOP_SET_FD failed: %m"); ioctl(loopfd, LOOP_CLR_FD, 0); close(targfd); close(loopfd); @@ -119,7 +119,7 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) { strncpy(loopInfo.lo_name, basename(fsystem), 63); if (ioctl(loopfd, LOOP_SET_STATUS, &loopInfo)) { - logMessage(ERROR, "LOOP_SET_STATUS failed: %s", strerror(errno)); + logMessage(ERROR, "LOOP_SET_STATUS failed: %m"); close(loopfd); return LOADER_ERROR; } @@ -133,7 +133,7 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) { if (doPwMount(filename, mntpoint, "squashfs", IMOUNT_RDONLY, NULL)) { if (doPwMount(filename, mntpoint, "cramfs", IMOUNT_RDONLY, NULL)) { if (doPwMount(filename, mntpoint, "vfat", IMOUNT_RDONLY, NULL)) { - logMessage(ERROR, "failed to mount loop: %s", strerror(errno)); + logMessage(ERROR, "failed to mount loop: %m"); loopfd = open(filename, O_RDONLY); ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); @@ -155,8 +155,8 @@ char * validIsoImages(char * dirName, int *foundinvalid) { if (!(dir = opendir(dirName))) { newtWinMessage(_("Error"), _("OK"), - _("Failed to read directory %s: %s"), - dirName, strerror(errno)); + _("Failed to read directory %s: %m"), + dirName); return 0; } @@ -373,8 +373,8 @@ void queryIsoMediaCheck(char *isoFile) { if (!(dir = opendir(isoDir))) { newtWinMessage(_("Error"), _("OK"), - _("Failed to read directory %s: %s"), - isoDir, strerror(errno)); + _("Failed to read directory %s: %m"), + isoDir); free(isoDir); free(master_timestamp); return; @@ -605,8 +605,8 @@ int copyFileAndLoopbackMount(int fd, char * dest, if (mountLoopback(dest, mntpoint, device)) { /* JKFIXME: this used to be fatal, but that seems unfriendly */ - logMessage(ERROR, "Error mounting /dev/%s on %s (%s)", device, - mntpoint, strerror(errno)); + logMessage(ERROR, "Error mounting /dev/%s on %s (%m)", device, + mntpoint); unlink(dest); return 1; } @@ -634,8 +634,7 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) { if (doPwMount("/tmp/srcdev", "/tmp/mnt", "vfat", IMOUNT_RDONLY, NULL) && doPwMount("/tmp/srcdev", "/tmp/mnt", "ext2", IMOUNT_RDONLY, NULL) && doPwMount("/tmp/srcdev", "/tmp/mnt", "iso9660", IMOUNT_RDONLY, NULL)) { - logMessage(ERROR, "failed to mount /dev/%s: %s", device, - strerror(errno)); + logMessage(ERROR, "failed to mount /dev/%s: %m", device); return 2; } diff --git a/loader2/modstubs.c b/loader2/modstubs.c index 0e01311..ad4e26f 100644 --- a/loader2/modstubs.c +++ b/loader2/modstubs.c @@ -130,19 +130,19 @@ int ourInsmodCommand(int argc, char ** argv) { return 1; if (stat(file, &sb) == -1) { - logMessage(ERROR, "unable to stat file %s: %s", file, strerror(errno)); + logMessage(ERROR, "unable to stat file %s: %m", file); return 1; } fd = open(file, O_RDONLY); if (fd < 0) { - logMessage(ERROR, "unable to open file %s: %s", file, strerror(errno)); + logMessage(ERROR, "unable to open file %s: %m", file); return 1; } modbuf = mmap(0, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (modbuf == NULL) { - logMessage(ERROR, "error reading file %s: %s", file, strerror(errno)); + logMessage(ERROR, "error reading file %s: %m", file); close(fd); return 1; } diff --git a/loader2/modules.c b/loader2/modules.c index ebe6cba..ac6fe3b 100644 --- a/loader2/modules.c +++ b/loader2/modules.c @@ -814,8 +814,7 @@ static int writeModulesConf(moduleList list, char *conf) { fd = open("/tmp/modprobe.conf", O_WRONLY | O_CREAT | O_APPEND, 0666); if (fd == -1) { - logMessage(ERROR, "error appending to /tmp/modprobe.conf: %s\n", - strerror(errno)); + logMessage(ERROR, "error appending to /tmp/modprobe.conf: %m\n"); return 0; } @@ -909,7 +908,7 @@ void writeScsiDisks(moduleList list) { if (!list) return; if ((fd = open("/tmp/scsidisks", O_WRONLY | O_CREAT, 0666)) == -1) { - logMessage(ERROR, "error opening /tmp/scsidisks: %s", strerror(errno)); + logMessage(ERROR, "error opening /tmp/scsidisks: %m"); return; } diff --git a/loader2/net.c b/loader2/net.c index d7138e8..eeb681a 100644 --- a/loader2/net.c +++ b/loader2/net.c @@ -228,16 +228,14 @@ void initLoopback(void) { strcpy(req.ifr_name, "lo"); if (ioctl(s, SIOCGIFFLAGS, &req)) { - logMessage(LOG_ERR, "ioctl SIOCGIFFLAGS failed: %d %s\n", errno, - strerror(errno)); + logMessage(LOG_ERR, "ioctl SIOCGIFFLAGS failed: %d %m\n", errno); close(s); return; } req.ifr_flags |= (IFF_UP | IFF_RUNNING); if (ioctl(s, SIOCSIFFLAGS, &req)) { - logMessage(LOG_ERR, "ioctl SIOCSIFFLAGS failed: %d %s\n", errno, - strerror(errno)); + logMessage(LOG_ERR, "ioctl SIOCSIFFLAGS failed: %d %m\n", errno); close(s); return; } @@ -1277,12 +1275,12 @@ int setupWireless(struct networkDeviceConfig *dev) { logMessage(INFO, "setting essid for %s to %s", dev->dev.device, dev->essid); if (set_essid(dev->dev.device, dev->essid) < 0) { - logMessage(ERROR, "failed to set essid: %s", strerror(errno)); + logMessage(ERROR, "failed to set essid: %m"); } if (dev->wepkey) { logMessage(INFO, "setting encryption key for %s", dev->dev.device); if (set_wep_key(dev->dev.device, dev->wepkey) < 0) { - logMessage(ERROR, "failed to set wep key: %s", strerror(errno)); + logMessage(ERROR, "failed to set wep key: %m"); } } @@ -1495,7 +1493,7 @@ int writeResolvConf(struct networkDeviceConfig * net) { f = fopen(filename, "w"); if (!f) { - logMessage(ERROR, "Cannot create %s: %s\n", filename, strerror(errno)); + logMessage(ERROR, "Cannot create %s: %m\n", filename); return LOADER_ERROR; } diff --git a/loader2/selinux.c b/loader2/selinux.c index 442fd67..81a8835 100644 --- a/loader2/selinux.c +++ b/loader2/selinux.c @@ -37,7 +37,7 @@ int loadpolicy() { setenv("LD_LIBRARY_PATH", LIBPATH, 1); execl("/usr/sbin/load_policy", "/usr/sbin/load_policy", "-q", NULL); - logMessage(ERROR, "exec of load_policy failed: %s", strerror(errno)); + logMessage(ERROR, "exec of load_policy failed: %m"); exit(1); } diff --git a/loader2/telnetd.c b/loader2/telnetd.c index c624740..551bf11 100644 --- a/loader2/telnetd.c +++ b/loader2/telnetd.c @@ -62,7 +62,7 @@ int beTelnet(void) { struct winsize ws; if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - logMessage(ERROR, "socket: %s", strerror(errno)); + logMessage(ERROR, "socket: %m"); return -1; } @@ -84,8 +84,7 @@ int beTelnet(void) { if ((conn = accept(sock, (struct sockaddr *) &address, &addrLength)) < 0) { - newtWinMessage(_("Error"), _("OK"), "accept failed: %s", - strerror(errno)); + newtWinMessage(_("Error"), _("OK"), "accept failed: %m"); close(sock); return -1; } @@ -191,7 +190,7 @@ int beTelnet(void) { if (i < 0) { - logMessage(ERROR, "poll: %s", strerror(errno)); + logMessage(ERROR, "poll: %m"); } #ifndef DEBUG_TELNET diff --git a/loader2/usb.c b/loader2/usb.c index 4c4e8a1..d762039 100644 --- a/loader2/usb.c +++ b/loader2/usb.c @@ -99,7 +99,7 @@ int usbInitialize(moduleList modLoaded, moduleDeps modDeps, if (FL_TESTING(flags)) return 0; if (doPwMount("/proc/bus/usb", "/proc/bus/usb", "usbfs", 0, NULL)) - logMessage(ERROR, "failed to mount device usbfs: %s", strerror(errno)); + logMessage(ERROR, "failed to mount device usbfs: %m"); /* sleep so we make sure usb devices get properly enumerated. that way we should block when initializing each usb driver until diff --git a/loader2/windows.h b/loader2/windows.h index c42da6d..7b39d92 100644 --- a/loader2/windows.h +++ b/loader2/windows.h @@ -7,6 +7,6 @@ void winStatus(int width, int height, char * title, char * text, ...); void scsiWindow(const char * driver); #define errorWindow(String) \ - newtWinMessage(_("Error"), _("OK"), String, strerror (errno)); + newtWinMessage(_("Error"), _("OK"), String); #endif /* _WINDOWS_H_ */ diff --git a/utils/mapshdr.c b/utils/mapshdr.c index 5a8d18f..ee91cea 100644 --- a/utils/mapshdr.c +++ b/utils/mapshdr.c @@ -20,8 +20,7 @@ int main(int argc, char ** argv) { for (i = 1; i < argc; i++) { if (stat(argv[i], &sb)) { - fprintf(stderr, "stat error for %s: %s\n", argv[i], - strerror(errno)); + fprintf(stderr, "stat error for %s: %m\n", argv[i]); exit(1); }
_______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list