rem: if (id < 0) { dprintf("error allocating bss region: %s!\n", strerror(id));
add: if (id < B_OK) { dprintf("error allocating bss area: %s!\n", strerror(id));
context: elf_load_user_image(const char *path, struct team *p, int flags, addr_t *entry){	struct Elf32_Ehdr eheader;	struct Elf32_Phdr *pheaders = NULL;	char baseName[64];	int fd;	int err;	int i;	ssize_t len;	TRACE(("elf_load: entry path '%s', team %p\n", path, p));	fd = _kern_open(-1, path, 0);	if (fd < 0)		return fd;	// read and verify the ELF header	len = _kern_read(fd, 0, &eheader, sizeof(eheader));	if (len < 0) {		err = len;		goto error;	}	if (len != sizeof(eheader)) {		// short read		err = B_NOT_AN_EXECUTABLE;		goto error;	}	err = verify_eheader(&eheader);	if (err < 0)		goto error;	// read program header	pheaders = (struct Elf32_Phdr *)malloc(eheader.e_phnum * eheader.e_phentsize);	if (pheaders == NULL) {		dprintf("error allocating space for program headers\n");		err = B_NO_MEMORY;		goto error;	}	TRACE(("reading in program headers at 0x%lx, len 0x%x\n", eheader.e_phoff, eheader.e_phnum * eheader.e_phentsize));	len = _kern_read(fd, eheader.e_phoff, pheaders, eheader.e_phnum * eheader.e_phentsize);	if (len < 0) {		err = len;		dprintf("error reading in program headers\n");		goto error;	}	if (len != eheader.e_phnum * eheader.e_phentsize) {		dprintf("short read while reading in program headers\n");		err = -1;		goto error;	}	// construct a nice name for the region we have to create below	{		int32 length = strlen(path);		if (length > 52)			sprintf(baseName, "...%s", path + length - 52);		else			strcpy(baseName, path);	}	// map the program's segments into memory	for (i = 0; i < eheader.e_phnum; i++) {		char regionName[64];		char *regionAddress;		area_id id;		if (pheaders[i].p_type != PT_LOAD)			continue;		regionAddress = (char *)ROUNDOWN(pheaders[i].p_vaddr, B_PAGE_SIZE);		if (pheaders[i].p_flags & PF_WRITE) {			/*			 * rw/data segment			 */			uint32 memUpperBound = (pheaders[i].p_vaddr % B_PAGE_SIZE) + pheaders[i].p_memsz;			uint32 fileUpperBound = (pheaders[i].p_vaddr % B_PAGE_SIZE) + pheaders[i].p_filesz;			memUpperBound = ROUNDUP(memUpperBound, B_PAGE_SIZE);			fileUpperBound = ROUNDUP(fileUpperBound, B_PAGE_SIZE);			sprintf(regionName, "%s_seg%drw", baseName, i);			id = vm_map_file(p->aspace->id, regionName,				(void **)&regionAddress,				B_EXACT_ADDRESS,				fileUpperBound,				B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP,				path, ROUNDOWN(pheaders[i].p_offset, B_PAGE_SIZE));			if (id < 0) {				dprintf("error allocating region: %s!\n", strerror(id));				err = B_NOT_AN_EXECUTABLE;				goto error;			}			// clean garbage brought by mmap (the region behind the file,			// at least parts of it are the bss and have to be zeroed)			{				uint32 start = (uint32)regionAddress					+ (pheaders[i].p_vaddr % B_PAGE_SIZE)					+ pheaders[i].p_filesz;				uint32 amount = fileUpperBound					- (pheaders[i].p_vaddr % B_PAGE_SIZE)					- (pheaders[i].p_filesz);				memset((void *)start, 0, amount);			}			// Check if we need extra storage for the bss - we have to do this if			// the above region doesn't already comprise the memory size, too.			if (memUpperBound != fileUpperBound) {				size_t bss_size = memUpperBound - fileUpperBound;				sprintf(regionName, "%s_bss%d", baseName, i);				regionAddress += fileUpperBound;				id = create_area_etc(p, regionName, (void **)&regionAddress,					B_EXACT_ADDRESS, bss_size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);				if (id < 0) {					dprintf("error allocating bss region: %s!\n", strerror(id));					err = B_NOT_AN_EXECUTABLE;					goto error;				}			}		} else {			/*			 * assume ro/text segment			 */			sprintf(regionName, "%s_seg%dro", baseName, i);			id = vm_map_file(p->aspace->id, regionName,				(void **)&regionAddress,				B_EXACT_ADDRESS,				ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % B_PAGE_SIZE), B_PAGE_SIZE),				B_READ_AREA | B_EXECUTE_AREA, REGION_PRIVATE_MAP,				path, ROUNDOWN(pheaders[i].p_offset, B_PAGE_SIZE));			if (id < 0) {				dprintf("error mapping text!\n");				err = B_NOT_AN_EXECUTABLE;				goto error;			}		}	}	TRACE(("elf_load: done!\n"));	*entry = eheader.e_entry;	err = B_OK;error:	if (pheaders)		free(pheaders);	_kern_close(fd);	return err;}