rem: if (name) { int name_len = strlen(name);  temp_name = (char *)kmalloc(min(name_len + 1, SYS_MAX_OS_NAME_LEN)); if (temp_name == NULL) return ENOMEM; strncpy(temp_name, name, SYS_MAX_OS_NAME_LEN-1); temp_name[SYS_MAX_OS_NAME_LEN-1] = 0; } else { temp_name = (char *)kmalloc(sizeof("default_sem_name")+1); if (temp_name == NULL) return ENOMEM; strcpy(temp_name, "default_sem_name"); }
add: name_len = min(strlen(name) + 1, SYS_MAX_OS_NAME_LEN); temp_name = (char *)kmalloc(name_len); if (temp_name == NULL) return ENOMEM; strlcpy(temp_name, name, name_len);
context: sem_id create_sem_etc(int count, const char *name, team_id owner){	int i;	int state;	sem_id retval = B_NO_MORE_SEMS;	char *temp_name;	if (sems_active == false)		return B_NO_MORE_SEMS;	if (name) {		int name_len = strlen(name);		temp_name = (char *)kmalloc(min(name_len + 1, SYS_MAX_OS_NAME_LEN));		if (temp_name == NULL)			return ENOMEM;		strncpy(temp_name, name, SYS_MAX_OS_NAME_LEN-1);		temp_name[SYS_MAX_OS_NAME_LEN-1] = 0;	}	else {		temp_name = (char *)kmalloc(sizeof("default_sem_name")+1);		if (temp_name == NULL)			return ENOMEM;		strcpy(temp_name, "default_sem_name");	}	state = disable_interrupts();	GRAB_SEM_LIST_LOCK();	// find the first empty spot	for (i=0; i<MAX_SEMS; i++) {		if (sems[i].id == -1) {			// make the sem id be a multiple of the slot it's in			if (i >= next_sem % MAX_SEMS)				next_sem += i - next_sem % MAX_SEMS;			else				next_sem += MAX_SEMS - (next_sem % MAX_SEMS - i);			sems[i].id = next_sem++;			sems[i].lock = 0;			GRAB_SEM_LOCK(sems[i]);			RELEASE_SEM_LIST_LOCK();			sems[i].q.tail = NULL;			sems[i].q.head = NULL;			sems[i].count = count;			sems[i].name = temp_name;			sems[i].owner = owner;			retval = sems[i].id;			RELEASE_SEM_LOCK(sems[i]);			goto out;		}	}	RELEASE_SEM_LIST_LOCK();	kfree(temp_name);out:	restore_interrupts(state);	return retval;}