Commit 9f648592 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

staging: wlags49: don't use custom implementation of atoi()

Kernel has its own method called simple_strtoul() to do such things.

Here we are using simple_strtoul(value, NULL, 0) because in original function
the recognized base is 10 or 16 and input data is assumed to be unsigned.
Signed-off-by: default avatarAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e4c3a24d
......@@ -3792,7 +3792,7 @@ static int write_int(struct file *file, const char *buffer, unsigned long count,
}
if (count > 0 ) {
proc_number[count] = 0;
nr = wl_atoi( proc_number );
nr = simple_strtoul(proc_number , NULL, 0);
*(unsigned int *)data = nr;
if ( nr & 0x8000 ) { //;?kludgy but it is unclear to me were else to place this
#if DBG
......
This diff is collapsed.
......@@ -1536,52 +1536,3 @@ int wl_get_tallies(struct wl_private *lp,
return ret;
}
/*******************************************************************************
* wl_atoi()
*******************************************************************************
*
* DESCRIPTION:
*
* Believe it or not, we need our own implementation of atoi in the kernel.
*
* PARAMETERS:
*
* string - the ASCII string to convert to an integer
*
* RETURNS:
*
* unsigned integer
*
******************************************************************************/
unsigned int wl_atoi( char *string )
{
unsigned int base = 10; //default to decimal
unsigned int value = 0;
unsigned int c;
int i = strlen( string );
if ( i > 2 && string[0] == '0' && ( string[1] | ('X'^'x') ) == 'x' ) {
base = 16;
string +=2;
}
while ( ( c = *string++ ) != '\0' ) {
if ( value > UINT_MAX / base ) { //test for overrun
DBG_FUNC( "wl_atoi" ); //don't overload the log file with good messages
DBG_ENTER( DbgInfo );
DBG_ERROR( DbgInfo, "string \"%s\", lenght exceeds expectations\n", string );
printk( "<1>string \"%s\", lenght exceeds expectations\n", string );
DBG_LEAVE( DbgInfo );
break;
}
c -= '0';
if ( 0 <= c && c <= 9 ) value = base * value + c;
else if ( base == 16 ) {
c += '0';
c |= 'A'^'a';
c = c - 'a'+ 10;
if ( 10 <= c && c <= 15 ) value = base * value + c;
}
}
return value;
} // wl_atoi
......@@ -100,6 +100,4 @@ void wl_process_updated_record( struct wl_private *lp );
void wl_process_assoc_status( struct wl_private *lp );
void wl_process_security_status( struct wl_private *lp );
unsigned int wl_atoi( char *string );
#endif // __WL_UTIL_H__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment