lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4DD7A5DB.7050000@bfs.de>
Date:	Sat, 21 May 2011 13:45:31 +0200
From:	walter harms <wharms@....de>
To:	Greg Kroah-Hartman <greg@...ah.com>, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup



Am 20.05.2011 20:45, schrieb matt mooney:
> On 11:08 Fri 20 May     , walter harms wrote:
>>
>>
>> Am 20.05.2011 06:36, schrieb matt mooney:
>>> Remove match_find() and replace with get_busid_idx(); change
>>> get_busid_priv(), add_match_busid(), and del_match_busid() to use
>>> get_busid_idx(); and cleanup code in the other functions.
>>>
>>> Signed-off-by: matt mooney <mfm@...eddisk.com>
>>> ---
>>>  drivers/staging/usbip/stub_main.c |  147 ++++++++++++++++++-------------------
>>>  1 files changed, 73 insertions(+), 74 deletions(-)
>>>
>>> diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
>>> index 0ca1462..00398a6 100644
>>> --- a/drivers/staging/usbip/stub_main.c
>>> +++ b/drivers/staging/usbip/stub_main.c
>>> @@ -50,82 +50,90 @@ static void init_busid_table(void)
>>>  	spin_lock_init(&busid_table_lock);
>>>  }
>>>  
>>> -int match_busid(const char *busid)
>>> +/*
>>> + * Find the index of the busid by name.
>>> + * Must be called with busid_table_lock held.
>>> + */
>>> +static int get_busid_idx(const char *busid)
>>>  {
>>>  	int i;
>>> +	int idx = -1;
>>>  
>>> -	spin_lock(&busid_table_lock);
>>>  	for (i = 0; i < MAX_BUSID; i++)
>>>  		if (busid_table[i].name[0])
>>>  			if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
>>> -				/* already registerd */
>>> -				spin_unlock(&busid_table_lock);
>>> -				return 0;
>>> +				idx = i;
>>> +				break;
>>>  			}
>>> -	spin_unlock(&busid_table_lock);
>>> -
>>> -	return 1;
>>> +	return idx;
>>>  }
>>>  
>>>  struct bus_id_priv *get_busid_priv(const char *busid)
>>>  {
>>> -	int i;
>>> +	int idx;
>>> +	struct bus_id_priv *bid = NULL;
>>>  
>>>  	spin_lock(&busid_table_lock);
>>> -	for (i = 0; i < MAX_BUSID; i++)
>>> -		if (busid_table[i].name[0])
>>> -			if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
>>> -				/* already registerd */
>>> -				spin_unlock(&busid_table_lock);
>>> -				return &(busid_table[i]);
>>> -			}
>>> +	idx = get_busid_idx(busid);
>>> +	if (idx >= 0)
>>> +		bid = &(busid_table[idx]);
>>>  	spin_unlock(&busid_table_lock);
>>>  
>>> -	return NULL;
>>> +	return bid;
>>>  }
>>>  
>>>  static int add_match_busid(char *busid)
>>>  {
>>>  	int i;
>>> -
>>> -	if (!match_busid(busid))
>>> -		return 0;
>>> +	int ret = -1;
>>>  
>>>  	spin_lock(&busid_table_lock);
>>> +	/* already registered? */
>>> +	if (get_busid_idx(busid) >= 0) {
>>> +		ret = 0;
>>> +		goto out;
>>> +	}
>>> +
>>>  	for (i = 0; i < MAX_BUSID; i++)
>>>  		if (!busid_table[i].name[0]) {
>>>  			strncpy(busid_table[i].name, busid, BUSID_SIZE);
>>
>> i am missing an if() here ??
> 
> I am not sure what you mean. It should be correct.
>  

ups, sorry my fault
missread it as strcmp() everything is fine now.

re,
 wh

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ