Reduced stack usage, especially the ethernet interface was pretty careless about this.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16746 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -726,21 +726,24 @@ static void domain_init(void)
|
||||
* system defined module_info structures
|
||||
*/
|
||||
|
||||
static void find_protocol_modules(void)
|
||||
static void
|
||||
find_protocol_modules(void)
|
||||
{
|
||||
void *ml = open_module_list(NETWORK_PROTOCOLS);
|
||||
size_t sz = B_PATH_NAME_LENGTH;
|
||||
char name[sz];
|
||||
void *ml;
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
size_t bufferSize = sizeof(name);
|
||||
struct net_module *nm = NULL;
|
||||
int rv;
|
||||
|
||||
ml = open_module_list(NETWORK_PROTOCOLS);
|
||||
|
||||
if (ml == NULL) {
|
||||
printf("failed to open the %s directory\n",
|
||||
NETWORK_PROTOCOLS);
|
||||
return;
|
||||
}
|
||||
|
||||
while (read_next_module_name(ml, name, &sz) == B_OK) {
|
||||
while (read_next_module_name(ml, name, &bufferSize) == B_OK) {
|
||||
nm = (struct net_module *)malloc(sizeof(struct net_module));
|
||||
if (!nm)
|
||||
return;
|
||||
@@ -754,7 +757,7 @@ static void find_protocol_modules(void)
|
||||
} else {
|
||||
free(nm);
|
||||
}
|
||||
sz = B_PATH_NAME_LENGTH;
|
||||
bufferSize = sizeof(name);
|
||||
}
|
||||
|
||||
close_module_list(ml);
|
||||
@@ -775,11 +778,12 @@ static void find_protocol_modules(void)
|
||||
* start_devices() they'll not do anything and other apps can use
|
||||
* them (AFAIK), so this shouldn't be an issue.
|
||||
*/
|
||||
static void find_interface_modules(void)
|
||||
static void
|
||||
find_interface_modules(void)
|
||||
{
|
||||
void *ml = open_module_list(NETWORK_INTERFACES);
|
||||
size_t sz = B_PATH_NAME_LENGTH;
|
||||
char name[sz];
|
||||
char name[B_FILE_NAME_LENGTH];
|
||||
size_t bufferSize = sizeof(name);
|
||||
struct net_module *nm = NULL;
|
||||
int rv;
|
||||
|
||||
@@ -789,7 +793,7 @@ static void find_interface_modules(void)
|
||||
return;
|
||||
}
|
||||
|
||||
while (read_next_module_name(ml, name, &sz) == B_OK) {
|
||||
while (read_next_module_name(ml, name, &bufferSize) == B_OK) {
|
||||
nm = (struct net_module *)malloc(sizeof(struct net_module));
|
||||
if (!nm)
|
||||
return;
|
||||
@@ -805,8 +809,8 @@ static void find_interface_modules(void)
|
||||
} else {
|
||||
free(nm);
|
||||
}
|
||||
|
||||
sz = B_PATH_NAME_LENGTH;
|
||||
|
||||
bufferSize = sizeof(name);
|
||||
}
|
||||
|
||||
close_module_list(ml);
|
||||
|
||||
@@ -220,17 +220,22 @@ static void attach_device(int devid, char *driver, char *devno)
|
||||
}
|
||||
}
|
||||
|
||||
static void open_device(char *driver, char *devno)
|
||||
|
||||
static void
|
||||
open_device(char *driver, char *devno)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
status_t status;
|
||||
int dev;
|
||||
status_t status = -1;
|
||||
|
||||
char *path = malloc(B_PATH_NAME_LENGTH);
|
||||
if (path == NULL)
|
||||
return;
|
||||
|
||||
sprintf(path, "%s/%s/%s", DRIVER_DIRECTORY, driver, devno);
|
||||
dev = open(path, O_RDWR);
|
||||
if (dev < B_OK) {
|
||||
printf("Unable to open %s, %ld [%s]\n", path,
|
||||
status, strerror(status));
|
||||
printf("Unable to open %s\n", path);
|
||||
free(path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,6 +244,7 @@ static void open_device(char *driver, char *devno)
|
||||
attach_device(dev, driver, devno);
|
||||
|
||||
close(dev);
|
||||
free(path);
|
||||
};
|
||||
|
||||
#if 0
|
||||
@@ -283,24 +289,28 @@ static void find_devices(char *root)
|
||||
}
|
||||
#else
|
||||
|
||||
static void find_devices(void)
|
||||
static void
|
||||
find_devices(void)
|
||||
{
|
||||
DIR *dir, *driv_dir;
|
||||
struct dirent *de, *dre;
|
||||
char path[PATH_MAX];
|
||||
char* path = malloc(B_PATH_NAME_LENGTH);
|
||||
if (path == NULL)
|
||||
return;
|
||||
|
||||
dir = opendir(DRIVER_DIRECTORY);
|
||||
if (!dir) {
|
||||
printf("Couldn't open the directory %s\n", DRIVER_DIRECTORY);
|
||||
free(path);
|
||||
return;
|
||||
}
|
||||
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
/* hmm, is it a driver? */
|
||||
if (strcmp(de->d_name, ".") == 0 ||
|
||||
strcmp(de->d_name, "..") == 0 ||
|
||||
strcmp(de->d_name, "server") == 0 ||
|
||||
strcmp(de->d_name, "stack") == 0)
|
||||
if (!strcmp(de->d_name, ".")
|
||||
|| !strcmp(de->d_name, "..")
|
||||
|| !strcmp(de->d_name, "server")
|
||||
|| !strcmp(de->d_name, "stack"))
|
||||
continue;
|
||||
|
||||
/* OK we assume it's a driver...but skip the ether driver
|
||||
@@ -308,7 +318,7 @@ static void find_devices(void)
|
||||
*/
|
||||
if (strcmp(de->d_name, "ether") == 0)
|
||||
continue;
|
||||
|
||||
|
||||
sprintf(path, "%s/%s", DRIVER_DIRECTORY, de->d_name);
|
||||
driv_dir = opendir(path);
|
||||
if (!driv_dir) {
|
||||
@@ -327,8 +337,7 @@ static void find_devices(void)
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return;
|
||||
free(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user