Fix the following compile errors with gcc-4.4.0-0.30 in rawhide:
loader.c:2085: error: offset ‘3’ outside bounds of constant string
copy.c:66: error: offset ‘3’ outside bounds of constant string
getparts.c:97: error: offset ‘3’ outside bounds of constant string
dirbrowser.c:86: error: offset ‘3’ outside bounds of constant string
fwloader.c:212: error: offset ‘3’ outside bounds of constant string
nfsinstall.c:92: error: offset ‘2’ outside bounds of constant string
nfsinstall.c:92: error: offset ‘3’ outside bounds of constant string
nfsinstall.c:92: error: offset ‘2’ outside bounds of constant string
nfsinstall.c:92: error: offset ‘3’ outside bounds of constant string
net.c:89: error: offset ‘2’ outside bounds of constant string
net.c:89: error: offset ‘3’ outside bounds of constant string
urls.c:139: error: offset ‘3’ outside bounds of constant string
undomounts.c:159: error: offset ‘3’ outside bounds of constant string
---
loader/copy.c | 11 +++++++++--
loader/dirbrowser.c | 14 ++++++++++----
loader/fwloader.c | 3 ++-
loader/getparts.c | 5 +++--
loader/loader.c | 3 ++-
loader/net.c | 2 +-
loader/nfsinstall.c | 2 +-
loader/undomounts.c | 5 +++--
loader/urls.c | 14 ++++++++++----
9 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/loader/copy.c b/loader/copy.c
index 1c61233..330f8f6 100644
--- a/loader/copy.c
+++ b/loader/copy.c
@@ -63,8 +63,15 @@ int copyDirectory(char * from, char * to, void (*warnFn)(char *),
errno = 0;
while ((ent = readdir(dir))) {
- if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
- continue;
+ if (strlen(ent->d_name) == 1) {
+ if (ent->d_name[0] == '.') {
+ continue;
+ }
+ } else if (strlen(ent->d_name) == 2) {
+ if (ent->d_name[0] == '.'&& ent->d_name[1] == '.') {
+ continue;
+ }
+ }
sprintf(filespec, "%s/%s", from, ent->d_name);
sprintf(filespec2, "%s/%s", to, ent->d_name);
diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c
index 6c713ec..47df574 100644
--- a/loader/dirbrowser.c
+++ b/loader/dirbrowser.c
@@ -83,10 +83,16 @@ static char ** get_file_list(char * dirname,
files = malloc(numfiles * sizeof(char *));
while ((entry = readdir(dir))) {
- if ((strlen(entry->d_name) == 1)&& !strncmp(entry->d_name, ".", 1))
- continue;
- if ((strlen(entry->d_name) == 2)&& !strncmp(entry->d_name, "..", 2))
- continue;
+ if (strlen(entry->d_name) == 1) {
+ if (entry->d_name[0] == '.') {
+ continue;
+ }
+ } else if (strlen(entry->d_name) == 2) {
+ if (entry->d_name[0] == '.'&& entry->d_name[1] == '.') {
+ continue;
+ }
+ }
+
if (filterfunc&& filterfunc(dirname, entry))
continue;
diff --git a/loader/fwloader.c b/loader/fwloader.c
index 2ab8c7f..d528571 100644
--- a/loader/fwloader.c
+++ b/loader/fwloader.c
@@ -195,6 +195,7 @@ static int get_netlink_msg(struct fw_loader *fwl, struct uevent *uevent)
size_t len;
ssize_t size;
static char buffer[2560];
+ const char *marker = "@";
char *pos;
char *msg = NULL, *path = NULL, *envz = NULL;
char *argv[] = { NULL };
@@ -209,7 +210,7 @@ static int get_netlink_msg(struct fw_loader *fwl, struct uevent *uevent)
size = sizeof (buffer) - 1;
buffer[size] = '\0';
- len = strcspn(buffer, "@");
+ len = strcspn(buffer, marker);
if (!buffer[len])
return -1;
diff --git a/loader/getparts.c b/loader/getparts.c
index 8d2b7c4..e731211 100644
--- a/loader/getparts.c
+++ b/loader/getparts.c
@@ -94,8 +94,9 @@ char **getPartitionsList(char * disk) {
break;
} else if (toknum == 2) {
/* if size is exactly 1 then ignore it as an extended */
- if (!strcmp(b, "1"))
- break;
+ if (strlen(b) == 1)
+ if (b[0] == '1')
+ break;
} else if (toknum == 3) {
/* this should be the partition name */
/* now we need to see if this is the block device or */
diff --git a/loader/loader.c b/loader/loader.c
index 98ea24c..c700ebb 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1783,6 +1783,7 @@ int main(int argc, char ** argv) {
moduleInfoSet modInfo;
char *url = NULL;
+ const char *pathsep = ":";
char ** argptr, ** tmparg;
char * anacondaArgs[50];
@@ -2082,7 +2083,7 @@ int main(int argc, char ** argv) {
path = getenv("PATH");
while (path&& path[0]) {
- int n = strcspn(path, ":");
+ int n = strcspn(path, pathsep);
char c, *binpath;
c = path[n];
diff --git a/loader/net.c b/loader/net.c
index 3a3fae9..63a24a8 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -86,7 +86,7 @@ static void cidrCallback(newtComponent co, void * dptr) {
abort();
}
- if (strcmp(data->ipv4, ""))
+ if (strlen(data->ipv4) != 0)
upper = 32;
#ifdef ENABLE_IPV6
} else if (co == data->cidr6Entry) {
diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c
index 1a81547..612e12f 100644
--- a/loader/nfsinstall.c
+++ b/loader/nfsinstall.c
@@ -89,7 +89,7 @@ static int nfsGetSetup(char ** hostptr, char ** dirptr) {
do {
rc = newtWinEntries(_("NFS Setup"), buf, 60, 5, 15,
24, entries, _("OK"), _("Back"), NULL);
- } while (!strcmp(newServer, "") || !strcmp(newDir, ""));
+ } while ((strlen(newServer) == 0) || (strlen(newDir) == 0));
free(buf);
free(entries[1].text);
diff --git a/loader/undomounts.c b/loader/undomounts.c
index 1884ce6..1436dad 100644
--- a/loader/undomounts.c
+++ b/loader/undomounts.c
@@ -133,6 +133,7 @@ void unmountFilesystems(void) {
struct loop_info li;
char * device;
struct stat sb;
+ const char *slashtmp = "/tmp", *slashdev = "/dev";
fd = open("/proc/mounts", O_RDONLY, 0);
if (fd< 1) {
@@ -156,8 +157,8 @@ void unmountFilesystems(void) {
while (*chptr != ' ') chptr++;
*chptr++ = '\0';
- if (strcmp(start, "/")&& strcmp(start, "/tmp")&&
- strcmp(start, "/dev")) {
+ if ((strlen(start) == 1)&& (start[0] == '/')&&
+ strcmp(start, slashtmp)&& strcmp(start, slashdev)) {
filesystems[numFilesystems].name = strdup(start);
filesystems[numFilesystems].what = FS;
filesystems[numFilesystems].mounted = 1;
diff --git a/loader/urls.c b/loader/urls.c
index a46e034..6fca6dc 100644
--- a/loader/urls.c
+++ b/loader/urls.c
@@ -134,12 +134,18 @@ static char * getLoginName(char * login, struct iurlinfo *ui) {
/* convert a UI to a URL, returns allocated string */
char *convertUIToURL(struct iurlinfo *ui) {
- char *login, *finalPrefix, *url, *p;
+ char *login, *url, *p;
+ char *finalPrefix = NULL;
- if (!strcmp(ui->prefix, "/"))
- finalPrefix = "/.";
- else
+ if (strlen(ui->prefix) == 1) {
+ if (ui->prefix[0] == '/') {
+ finalPrefix = "/.";
+ }
+ }
+
+ if (finalPrefix == NULL) {
finalPrefix = ui->prefix;
+ }
login = "";
login = getLoginName(login, ui);