Fixes error message on error in carrier file 61/310861/1
authorDaniil Ruban <intx82@gmail.com>
Thu, 9 May 2024 05:05:25 +0000 (07:05 +0200)
committerDaniil Ruban <intx82@gmail.com>
Thu, 9 May 2024 05:06:13 +0000 (07:06 +0200)
- Fix based on https://bugzilla.redhat.com/show_bug.cgi?id=1253797
- In short: If on read carrier file EINVAL happens - that's not an error, but shows that interface is disabled

Change-Id: I92f660e6e214f3ba7d710fcf192952550a947bd8
Signed-off-by: Daniil Ruban <intx82@gmail.com>
src/network-monitor.c

index 4d9b85cd1aba8ff2c22a828d7bcc094cde5db2a4..d456335ac3b4474a5ff6ee22b8cd57d4fc3c6439 100755 (executable)
@@ -60,10 +60,15 @@ int netconfig_ethernet_cable_plugin_status_check()
        errno = 0;
        rv = fscanf(fd, "%d", &ret);
        if (rv < 0) {
-               ERR("Error! Failed to read from file, rv:[%d], error:[%s]",
-                               rv, strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
-               fclose(fd);
-               return -1;
+               // EINVAL is not error -> https://bugzilla.redhat.com/show_bug.cgi?id=1253797
+               if (errno == EINVAL) {
+                       ret = 0;
+               } else {
+                       ERR("Error! Failed to read from file, rv:[%d], error:[%s]",
+                                       rv, strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
+                       fclose(fd);
+                       return -1;
+               }
        }
 
        if (ret == 1) {