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
|
* system defined module_info structures
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void find_protocol_modules(void)
|
static void
|
||||||
|
find_protocol_modules(void)
|
||||||
{
|
{
|
||||||
void *ml = open_module_list(NETWORK_PROTOCOLS);
|
void *ml;
|
||||||
size_t sz = B_PATH_NAME_LENGTH;
|
char name[B_FILE_NAME_LENGTH];
|
||||||
char name[sz];
|
size_t bufferSize = sizeof(name);
|
||||||
struct net_module *nm = NULL;
|
struct net_module *nm = NULL;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
ml = open_module_list(NETWORK_PROTOCOLS);
|
||||||
|
|
||||||
if (ml == NULL) {
|
if (ml == NULL) {
|
||||||
printf("failed to open the %s directory\n",
|
printf("failed to open the %s directory\n",
|
||||||
NETWORK_PROTOCOLS);
|
NETWORK_PROTOCOLS);
|
||||||
return;
|
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));
|
nm = (struct net_module *)malloc(sizeof(struct net_module));
|
||||||
if (!nm)
|
if (!nm)
|
||||||
return;
|
return;
|
||||||
@@ -754,7 +757,7 @@ static void find_protocol_modules(void)
|
|||||||
} else {
|
} else {
|
||||||
free(nm);
|
free(nm);
|
||||||
}
|
}
|
||||||
sz = B_PATH_NAME_LENGTH;
|
bufferSize = sizeof(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
close_module_list(ml);
|
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
|
* start_devices() they'll not do anything and other apps can use
|
||||||
* them (AFAIK), so this shouldn't be an issue.
|
* 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);
|
void *ml = open_module_list(NETWORK_INTERFACES);
|
||||||
size_t sz = B_PATH_NAME_LENGTH;
|
char name[B_FILE_NAME_LENGTH];
|
||||||
char name[sz];
|
size_t bufferSize = sizeof(name);
|
||||||
struct net_module *nm = NULL;
|
struct net_module *nm = NULL;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
@@ -789,7 +793,7 @@ static void find_interface_modules(void)
|
|||||||
return;
|
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));
|
nm = (struct net_module *)malloc(sizeof(struct net_module));
|
||||||
if (!nm)
|
if (!nm)
|
||||||
return;
|
return;
|
||||||
@@ -806,7 +810,7 @@ static void find_interface_modules(void)
|
|||||||
free(nm);
|
free(nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
sz = B_PATH_NAME_LENGTH;
|
bufferSize = sizeof(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
close_module_list(ml);
|
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;
|
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);
|
sprintf(path, "%s/%s/%s", DRIVER_DIRECTORY, driver, devno);
|
||||||
dev = open(path, O_RDWR);
|
dev = open(path, O_RDWR);
|
||||||
if (dev < B_OK) {
|
if (dev < B_OK) {
|
||||||
printf("Unable to open %s, %ld [%s]\n", path,
|
printf("Unable to open %s\n", path);
|
||||||
status, strerror(status));
|
free(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +244,7 @@ static void open_device(char *driver, char *devno)
|
|||||||
attach_device(dev, driver, devno);
|
attach_device(dev, driver, devno);
|
||||||
|
|
||||||
close(dev);
|
close(dev);
|
||||||
|
free(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -283,24 +289,28 @@ static void find_devices(char *root)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static void find_devices(void)
|
static void
|
||||||
|
find_devices(void)
|
||||||
{
|
{
|
||||||
DIR *dir, *driv_dir;
|
DIR *dir, *driv_dir;
|
||||||
struct dirent *de, *dre;
|
struct dirent *de, *dre;
|
||||||
char path[PATH_MAX];
|
char* path = malloc(B_PATH_NAME_LENGTH);
|
||||||
|
if (path == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
dir = opendir(DRIVER_DIRECTORY);
|
dir = opendir(DRIVER_DIRECTORY);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
printf("Couldn't open the directory %s\n", DRIVER_DIRECTORY);
|
printf("Couldn't open the directory %s\n", DRIVER_DIRECTORY);
|
||||||
|
free(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((de = readdir(dir)) != NULL) {
|
while ((de = readdir(dir)) != NULL) {
|
||||||
/* hmm, is it a driver? */
|
/* hmm, is it a driver? */
|
||||||
if (strcmp(de->d_name, ".") == 0 ||
|
if (!strcmp(de->d_name, ".")
|
||||||
strcmp(de->d_name, "..") == 0 ||
|
|| !strcmp(de->d_name, "..")
|
||||||
strcmp(de->d_name, "server") == 0 ||
|
|| !strcmp(de->d_name, "server")
|
||||||
strcmp(de->d_name, "stack") == 0)
|
|| !strcmp(de->d_name, "stack"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* OK we assume it's a driver...but skip the ether driver
|
/* OK we assume it's a driver...but skip the ether driver
|
||||||
@@ -327,8 +337,7 @@ static void find_devices(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
free(path);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user