[rhel5-branch 4/4] Shorten long NIC descriptions to 60.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Else it doesn't fit on the 80 chars wide terminal and the user can't see
them anyway. Especially the InfiniBand devices tend to be called long
names.

Related: rhbz#660684
---
 loader2/net.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/loader2/net.c b/loader2/net.c
index ee63154..dc84983 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -2184,6 +2184,8 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
     char **devices;
     char **deviceNames;
     char *ksMacAddr = NULL, *seconds = strdup("10"), *idstr = NULL;
+    const unsigned MAX_DESC = 60;
+    char desc[MAX_DESC];
     struct device **devs;
     struct newtWinEntry entry[] = {{_("Seconds:"), (const char **) &seconds, 0},
                                    {NULL, NULL, 0 }};
@@ -2212,10 +2214,17 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
         if (!devs[i]->device)
             continue;
         if (devs[i]->desc) {
+                if (strlen(devs[i]->desc) < MAX_DESC) {
+                    strcpy(desc, devs[i]->desc);
+                } else {
+                    strncpy(desc, devs[i]->desc, MAX_DESC);
+                    desc[MAX_DESC - 4] = '\0';
+                    strcat(desc, "...");
+                }
                 deviceNames[deviceNums] = alloca(strlen(devs[i]->device) +
-                                          strlen(devs[i]->desc) + 4);
+                                                 strlen(desc) + 4);
                 sprintf(deviceNames[deviceNums],"%s - %s",
-                        devs[i]->device, devs[i]->desc);
+                        devs[i]->device, desc);
                 if (strlen(deviceNames[deviceNums]) > max)
                         max = strlen(deviceNames[deviceNums]);
                 devices[deviceNums++] = devs[i]->device;
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux