hexdigits definition consolidation [RESEND2]
Subsystems (15)
Hello,
This is a resend of the patch I sent around an hour ago. Please ignore the previous one as it will break ide.c
Quoted 10 lines · Matthew Wilcox
Quoted 3 lines · Masoud Sharbiani
Hello,
The following patch consolidates several definitions of hex digits as string that are spread throughout the kernel and drivers. I had to create a separate file inlib/directory to hold the actual values, andEXPORT_SYMBOLthem them so that they could be used by modules.Definitely something worth looking at consolidating. Some comments though ...
-
vsprintf.ccontains a routine ('number') which actually handles multiple bases. It should be consolidated with this.
Done.
Quoted 2 lines
- Instead of introducing a new lib file and a new header file, how about exporting all this via
vsprintf.cand <linux/kernel.h>?
Also done.
Quoted 1 line
- I prefer the longer names 'hexchar' to just 'hex'.
How about small_digits and large_digits that are already there in lib/vsprint.c?
Quoted 4 lines
- A lot of these look like open coded versions of using
sprintf(dest, "%x", arg);
- Some seem to be unnecessary implementations of common library functions. eggdb_cris_strtol()could usesimple_strtol()instead.
I'll hopefully do this one in a separate patch hopefully tomorrow.
cheers,
Masoud
arch/cris/arch-v10/kernel/kgdb.c +2 -3
@@ -415,7 +415,6 @@#define RUNLENMAX 64/* Definition of all valid hexadecimal characters */ -static const char hexchars[] ="0123456789abcdef" ;/* The inbound/outbound buffers used in packet I/O */ static char remcomInBuffer[BUFMAX ];
@@ -557,8 +556,8 @@char *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {
arch/cris/arch-v32/kernel/kgdb.c +4 -5
@@ -465,7 +465,6 @@#define RUNLENMAX 64/* Definition of all valid hexadecimal characters */ -static const char hexchars[] ="0123456789abcdef" ;/* The inbound/outbound buffers used in packet I/O */ static char input_buffer[BUFMAX ];
@@ -550,8 +549,8 @@char *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {/* Unconverted suffix is stored in endptr unless endptr is NULL. */
@@ -660,7 +659,7 @@static inline char highhex (int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
@@ -668,7 +667,7 @@static inline char lowhex (int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }/* Returns the integer equivalent of a hexadecimal character. */
arch/frv/kernel/gdb-stub.c +50 -52
182 lines not on this page · raw message
arch/mips/au1000/common/puts.c +2 -3
@@ -39,7 +39,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned long *const com1 = (unsigned long *)SERIAL_BASE ;
@@ -124,7 +123,7 @@do { cnt--; ch = (unsigned char )(ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -140,6 +139,6 @@do { cnt--; ch = (unsigned char )(u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/galileo-boards/ev96100/puts.c +2 -3
@@ -21,7 +21,6 @@#define TIMEOUT 0xffff#undef SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned char *const com1 = (unsigned char *)SERIAL_BASE ;
@@ -118,7 +117,7 @@do { cnt--; ch = (unsigned char ) (ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -133,6 +132,6 @@do { cnt--; ch = (unsigned char ) (u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/ite-boards/generic/puts.c +2 -3
@@ -38,7 +38,6 @@#define TIMEOUT 0xffff#undef SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned char *const com1 = (unsigned char *)SERIAL_BASE ;
@@ -119,7 +118,7 @@do { cnt--; ch = (unsigned char ) (ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -134,6 +133,6 @@do { cnt--; ch = (unsigned char ) (u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/jmr3927/common/puts.c +2 -4
@@ -40,8 +40,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ; -#ifdef SLOW_DOWN #define slow_down () { int k; for (k=0; k<10000; k++); }#else
@@ -147,7 +145,7 @@do { cnt--; ch = (unsigned char )(ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -163,6 +161,6 @@do { cnt--; ch = (unsigned char )(u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/jmr3927/rbhma3100/kgdb_io.c +0 -2
@@ -39,8 +39,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ; -#ifdef SLOW_DOWN #define slow_down () { int k; for (k=0; k<10000; k++); }#else
arch/mips/kernel/gdb-stub.c +14 -15
@@ -189,7 +189,6 @@static char output_buffer[BUFMAX ];static int initialized;/* !0 means we've been initialized */ static int kgdb_started; -static const char hexchars[]="0123456789abcdef" ;/* Used to prevent crashes in memory access. Note that they'll crash anyway if we haven't set up fault handlers yet... */
@@ -305,8 +304,8 @@ }putDebugChar ('#' ); -putDebugChar (hexchars[checksum >>4 ]); -putDebugChar (hexchars[checksum &0xf ]); +putDebugChar (small_digits[checksum >>4 ]); +putDebugChar (small_digits[checksum &0xf ]); }while ((getDebugChar () &0x7f ) !='+' );
@@ -327,8 +326,8 @@while (count-- >0 ) {if (kgdb_read_byte (mem++, &ch) !=0 )return 0 ; - *buf++ = hexchars[ch >>4 ]; - *buf++ = hexchars[ch &0xf ]; + *buf++ = small_digits[ch >>4 ]; + *buf++ = small_digits[ch &0xf ]; } *buf =0 ;
@@ -748,14 +747,14 @@* Send trap type (converted to signal) */ *ptr++ ='T' ; - *ptr++ = hexchars[sigval >>4 ]; - *ptr++ = hexchars[sigval &0xf ]; + *ptr++ = small_digits[sigval >>4 ]; + *ptr++ = small_digits[sigval &0xf ];/* * Send Error PC */ - *ptr++ = hexchars[REG_EPC >>4 ]; - *ptr++ = hexchars[REG_EPC &0xf ]; + *ptr++ = small_digits[REG_EPC >>4 ]; + *ptr++ = small_digits[REG_EPC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->cp0_epc, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -763,8 +762,8 @@/* * Send frame pointer */ - *ptr++ = hexchars[REG_FP >>4 ]; - *ptr++ = hexchars[REG_FP &0xf ]; + *ptr++ = small_digits[REG_FP >>4 ]; + *ptr++ = small_digits[REG_FP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->reg30, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -772,8 +771,8 @@/* * Send stack pointer */ - *ptr++ = hexchars[REG_SP >>4 ]; - *ptr++ = hexchars[REG_SP &0xf ]; + *ptr++ = small_digits[REG_SP >>4 ]; + *ptr++ = small_digits[REG_SP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->reg29, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -792,8 +791,8 @@ {case '?' : output_buffer[0 ] ='S' ; - output_buffer[1 ] = hexchars[sigval >>4 ]; - output_buffer[2 ] = hexchars[sigval &0xf ]; + output_buffer[1 ] = small_digits[sigval >>4 ]; + output_buffer[2 ] = small_digits[sigval &0xf ]; output_buffer[3 ] =0 ;break ;
arch/ppc/boot/common/misc-common.c +4 -4
@@ -280,7 +280,7 @@int i;for (i =7 ; i >=0 ; i--) { - buf[i] ="0123456789ABCDEF" [val &0x0F ]; + buf[i] = small_digits[val &0x0F ]; val >>=4 ; } buf[8 ] ='\0' ;
@@ -362,13 +362,13 @@ sign ='-' ; val = -val; } - length =_cvt (val, buf,10 ,"0123456789" ); + length =_cvt (val, buf,10 , decimal);break ;case 'x' : - length =_cvt (val, buf,16 ,"0123456789abcdef" ); + length =_cvt (val, buf,16 , hex);break ;case 'X' : - length =_cvt (val, buf,16 ,"0123456789ABCDEF" ); + length =_cvt (val, buf,16 ,HEX );break ; } cp = buf;
arch/ppc/kernel/ppc-stub.c +24 -25
90 lines not on this page · raw message
arch/ppc/kernel/process.c +1 -1
@@ -695,7 +695,7 @@int i;for (i =7 ; i >=0 ; i--) { - buf[i] ="0123456789ABCDEF" [val &0x0F ]; + buf[i] = large_digits[val &0x0F ]; val >>=4 ; } buf[8 ] ='\0' ;
arch/ppc/platforms/apus_setup.c +1 -2
@@ -627,10 +627,9 @@void __debug_print_hex (unsigned long x) {int i; -char hexchars[] ="0123456789ABCDEF" ;for (i =0 ; i <8 ; i++) { -__debug_ser_out (hexchars[(x >>28 ) &15 ]); +__debug_ser_out (large_digits[(x >>28 ) &15 ]); x <<=4 ; }__debug_ser_out ('\n' );
arch/ppc/platforms/residual.c +4 -5
@@ -770,15 +770,14 @@unsigned short Number, char * str) { -static unsigned const char hexdigit[]="0123456789ABCDEF" ; if (strlen(str)!=7) return 0; if ( ( ((vendor>>10)&0x1f)+'A'-1 == str[0]) && ( ((vendor>>5)&0x1f)+'A'-1 == str[1]) && ( (vendor&0x1f)+'A'-1 == str[2]) && - (hexdigit[(Number>>12 )&0x0f ] == str[3 ]) && - (hexdigit[(Number>>8 )&0x0f ] == str[4 ]) && - (hexdigit[(Number>>4 )&0x0f ] == str[5 ]) && - (hexdigit[Number&0x0f ] == str[6 ]) )return 1 ; + (large_digits[(Number>>12 )&0x0f ] == str[3 ]) && + (large_digits[(Number>>8 )&0x0f ] == str[4 ]) && + (large_digits[(Number>>4 )&0x0f ] == str[5 ]) && + (large_digits[Number&0x0f] == str[6]) ) return 1;return 0 ; }
arch/ppc/syslib/btext.c +8 -9
@@ -392,18 +392,17 @@ void BTEXTbtext_drawhex (unsigned long v) { -static char hex_table[] ="0123456789abcdef" ;if (!boot_text_mapped)return ; -btext_drawchar (hex_table[(v >>28 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>24 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>20 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>16 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>12 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>8 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>4 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>0 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>28 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>24 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>20 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>16 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>12 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>8 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>4 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>0 ) &0x0000000FUL ]);btext_drawchar (' ' ); }
arch/ppc64/kernel/btext.c +16 -18
@@ -278,26 +278,24 @@void btext_drawhex (unsigned long v) { -char *hex_table ="0123456789abcdef" ; -if (!boot_text_mapped)return ; -btext_drawchar (hex_table[(v >>60 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>56 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>52 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>48 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>44 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>40 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>36 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>32 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>28 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>24 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>20 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>16 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>12 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>8 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>4 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>0 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>60 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>56 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>52 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>48 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>44 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>40 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>36 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>32 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>28 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>24 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>20 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>16 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>12 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>8 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>4 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>0 ) &0x0000000FUL ]);btext_drawchar (' ' ); }
arch/ppc64/kernel/mf.c +4 -4
@@ -643,10 +643,10 @@ 72); src[6 ] = value >>8 ; src[7 ] = value &255 ; - src[44 ] ="0123456789ABCDEF" [(value >>12 ) &15 ]; - src[45 ] ="0123456789ABCDEF" [(value >>8 ) &15 ]; - src[46 ] ="0123456789ABCDEF" [(value >>4 ) &15 ]; - src[47 ] ="0123456789ABCDEF" [value &15 ]; + src[44 ] = large_digits[(value >>12 ) &15 ]; + src[45 ] = large_digits[(value >>8 ) &15 ]; + src[46 ] = large_digits[(value >>4 ) &15 ]; + src[47 ] = large_digits[value &15 ];dma_and_signal_ce_msg (ce,NULL , src,sizeof (src),9 *64 *1024 ); }
arch/sh/kernel/kgdb_stub.c +4 -5
@@ -240,7 +240,6 @@/* Misc static */ static int stepped_address;static short stepped_opcode; -static const char hexchars[] ="0123456789abcdef" ;static char in_buffer[BUFMAX ];static char out_buffer[OUTBUFMAX ];
@@ -268,13 +267,13 @@/* Get high hex bits */ static char highhex (const int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }/* Get low hex bits */ static char lowhex (const int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }/* Convert ch to hex */
@@ -367,8 +366,8 @@/* Pack a hex byte */ static char *pack_hex_byte (char *pkt,int byte) { - *pkt++ = hexchars[(byte >>4 ) &0xf ]; - *pkt++ = hexchars[(byte &0xf )]; + *pkt++ = small_digits[(byte >>4 ) &0xf ]; + *pkt++ = small_digits[(byte &0xf )];return pkt; }
arch/sparc/kernel/sparc-stub.c +18 -20
@@ -127,8 +127,6 @@static int initialized;/* !0 means we've been initialized */ -static const char hexchars[]="0123456789abcdef" ; -#define NUMREGS 72/* Number of bytes of registers. */
@@ -298,8 +296,8 @@ }putDebugChar ('#' ); -putDebugChar (hexchars[checksum >>4 ]); -putDebugChar (hexchars[checksum &0xf ]); +putDebugChar (small_digits[checksum >>4 ]); +putDebugChar (small_digits[checksum &0xf ]); recv =getDebugChar (); }while ((recv &0x7f ) !='+' ); }
@@ -337,8 +335,8 @@ ".word 1b, 2b\n\t" ".text\n" : "=r" (mem), "=r" (ch) : "0" (mem)); - *buf++ = hexchars[ch >>4 ]; - *buf++ = hexchars[ch &0xf ]; + *buf++ = small_digits[ch >>4 ]; + *buf++ = small_digits[ch &0xf ]; } *buf =0 ;
@@ -527,35 +525,35 @@ ptr = remcomOutBuffer; *ptr++ ='T' ; - *ptr++ = hexchars[sigval >>4 ]; - *ptr++ = hexchars[sigval &0xf ]; + *ptr++ = small_digits[sigval >>4 ]; + *ptr++ = small_digits[sigval &0xf ]; - *ptr++ = hexchars[PC >>4 ]; - *ptr++ = hexchars[PC &0xf ]; + *ptr++ = small_digits[PC >>4 ]; + *ptr++ = small_digits[PC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[PC ], ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[FP >>4 ]; - *ptr++ = hexchars[FP &0xf ]; + *ptr++ = small_digits[FP >>4 ]; + *ptr++ = small_digits[FP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *) (sp +8 +6 ), ptr,4 );/* FP */ *ptr++ =';' ; - *ptr++ = hexchars[SP >>4 ]; - *ptr++ = hexchars[SP &0xf ]; + *ptr++ = small_digits[SP >>4 ]; + *ptr++ = small_digits[SP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)&sp, ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[NPC >>4 ]; - *ptr++ = hexchars[NPC &0xf ]; + *ptr++ = small_digits[NPC >>4 ]; + *ptr++ = small_digits[NPC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[NPC ], ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[O7 >>4 ]; - *ptr++ = hexchars[O7 &0xf ]; + *ptr++ = small_digits[O7 >>4 ]; + *ptr++ = small_digits[O7 &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[O7 ], ptr,4 ); *ptr++ =';' ;
@@ -577,8 +575,8 @@switch (remcomInBuffer[0 ]) {case '?' : remcomOutBuffer[0 ] ='S' ; - remcomOutBuffer[1 ] = hexchars[sigval >>4 ]; - remcomOutBuffer[2 ] = hexchars[sigval &0xf ]; + remcomOutBuffer[1 ] = small_digits[sigval >>4 ]; + remcomOutBuffer[2 ] = small_digits[sigval &0xf ]; remcomOutBuffer[3 ] =0 ;break ;
drivers/isdn/icn/icn.c +1 -1
@@ -1385,7 +1385,7 @@ c->parm.num[0] ? "N" : "ALL", c->parm.num); }else sprintf (cbuf,"%02d;EAZ%s\n" , (int ) a, - c->parm.num[0 ] ? (char *)(c->parm.num) :"0123456789" ); + c->parm.num[0 ] ? (char *)(c->parm.num) : decimal); i =icn_writecmd (cbuf,strlen (cbuf),0 , card); }break ;
drivers/isdn/isdnloop/isdnloop.c +1 -1
@@ -1297,7 +1297,7 @@ c->parm.num[0] ? "N" : "ALL", c->parm.num); }else sprintf (cbuf,"%02d;EAZ%s\n" , (int ) a, - c->parm.num[0 ] ? c->parm.num : (u_char *)"0123456789" ); + c->parm.num[0 ] ? c->parm.num : decimal); i =isdnloop_writecmd (cbuf,strlen (cbuf),0 , card); }break ;
drivers/net/irda/ma600.c +3 -7
@@ -54,10 +54,6 @@ func}#endif -/* convert hex value to ascii hex */ -static const char hexTbl[] ="0123456789ABCDEF" ; - -static void ma600_open (dongle_t *self,struct qos_info *qos);static void ma600_close (dongle_t *self);static int ma600_change_speed (struct irda_task *task);
@@ -243,10 +239,10 @@/* if control byte != echo, I don't know what to do */ printk (KERN_WARNING "%s() control byte written != read!\n" , __FUNCTION__);printk (KERN_WARNING "control byte = 0x%c%c\n" , - hexTbl[(byte>>4 )&0x0f ], hexTbl[byte&0x0f ]); + large_digits[(byte>>4 )&0x0f ], large_digits[byte&0x0f ]);printk (KERN_WARNING "byte echo = 0x%c%c\n" , - hexTbl[(byte_echo>>4 ) &0x0f ], - hexTbl[byte_echo &0x0f ]); + large_digits[(byte_echo>>4 ) &0x0f ], + large_digits[byte_echo &0x0f ]); #ifndef NDEBUG }else {IRDA_DEBUG (2 ,"%s() control byte write read OK\n" , __FUNCTION__);
drivers/net/sk98lin/skge.c +11 -12
@@ -4810,7 +4810,6 @@int haddr, addr;char hex_buffer[180 ];char asc_buffer[180 ]; -char HEXCHAR [] ="0123456789ABCDEF" ; addr =0 ; haddr =0 ;
@@ -4823,9 +4822,9 @@ asc_buffer[addr] ='.' ; addr++; asc_buffer[addr] =0 ; - hex_buffer[haddr] =HEXCHAR [(*p &0xf0 ) >>4 ]; + hex_buffer[haddr] = large_digits[(*p &0xf0 ) >>4 ]; haddr++; - hex_buffer[haddr] =HEXCHAR [*p &0x0f ]; + hex_buffer[haddr] = large_digits[*p &0x0f ]; haddr++; hex_buffer[haddr] =' ' ; haddr++;
@@ -4858,7 +4857,7 @@int haddr, addr;char hex_buffer[180 ];char asc_buffer[180 ]; -char HEXCHAR [] ="0123456789ABCDEF" ; +char large_digits[] ="0123456789ABCDEF" ;long *p;int l;
@@ -4869,21 +4868,21 @@ p = (long *) pc;for (i=0 ; i < size; ) { l = (long ) *p; - hex_buffer[haddr] =HEXCHAR [(l >>28 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>28 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>24 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>24 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>20 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>20 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>16 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>16 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>12 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>12 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>8 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>8 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>4 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>4 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [l &0x0f ]; + hex_buffer[haddr] = large_digits[l &0x0f ]; haddr++; hex_buffer[haddr] =' ' ; haddr++;
drivers/net/skfp/smt.c +1 -1
@@ -1731,7 +1731,7 @@#endif #ifdef DEBUG -#define hextoasc (x) "0123456789abcdef"[x] +#define hextoasc (x) small_digits[x]char *addr_to_string (struct fddi_addr *addr) {
drivers/net/wireless/strip.c +12 -14
@@ -404,8 +404,6 @@ (S)->battery_voltage.c[0] && \ memcmp(&(S)->true_dev_addr, zero_address.c, sizeof(zero_address))) -static const char hextable[16 ] ="0123456789ABCDEF" ; -static const MetricomAddress zero_address;static const MetricomAddress broadcast_address = { {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF } };
@@ -1292,13 +1290,13 @@__u8 *p = buffer;while (p < end) sum += *p++; - end[3 ] = hextable[sum &0xF ]; + end[3 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[2 ] = hextable[sum &0xF ]; + end[2 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[1 ] = hextable[sum &0xF ]; + end[1 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[0 ] = hextable[sum &0xF ]; + end[0 ] = large_digits[sum &0xF ];return (end +4 ); }
@@ -1379,15 +1377,15 @@ *ptr++ =0x0D ; *ptr++ ='*' ; - *ptr++ = hextable[haddr.c[2 ] >>4 ]; - *ptr++ = hextable[haddr.c[2 ] &0xF ]; - *ptr++ = hextable[haddr.c[3 ] >>4 ]; - *ptr++ = hextable[haddr.c[3 ] &0xF ]; + *ptr++ = large_digits[haddr.c[2 ] >>4 ]; + *ptr++ = large_digits[haddr.c[2 ] &0xF ]; + *ptr++ = large_digits[haddr.c[3 ] >>4 ]; + *ptr++ = large_digits[haddr.c[3 ] &0xF ]; *ptr++ ='-' ; - *ptr++ = hextable[haddr.c[4 ] >>4 ]; - *ptr++ = hextable[haddr.c[4 ] &0xF ]; - *ptr++ = hextable[haddr.c[5 ] >>4 ]; - *ptr++ = hextable[haddr.c[5 ] &0xF ]; + *ptr++ = large_digits[haddr.c[4 ] >>4 ]; + *ptr++ = large_digits[haddr.c[4 ] &0xF ]; + *ptr++ = large_digits[haddr.c[5 ] >>4 ]; + *ptr++ = large_digits[haddr.c[5 ] &0xF ]; *ptr++ ='*' ; *ptr++ = key.c[0 ]; *ptr++ = key.c[1 ];
drivers/pnp/pnpbios/rsparser.c +0 -2
@@ -481,8 +481,6 @@void pnpid32_to_pnpid (u32 id,char *str) { -const char *hex ="0123456789abcdef" ; - id =be32_to_cpu (id); str[0 ] =CHAR (id,26 ); str[1 ] =CHAR (id,21 );
drivers/scsi/ibmmca.c +0 -1
@@ -1007,7 +1007,6 @@/* interpreter for logical device numbers (ldn) */ static char *ti_l (int val) { -const char hex[16 ] ="0123456789abcdef" ;static char answer[2 ]; answer[1 ] = (char ) (0x0 );
drivers/scsi/ultrastor.c +2 -2
@@ -869,8 +869,8 @@for (i =0 ; i <16 ; i++) {unsigned char p =inb (port0 + i); - out[28 + i *3 ] ="0123456789abcdef" [p >>4 ]; - out[29 + i *3 ] ="0123456789abcdef" [p &15 ]; + out[28 + i *3 ] = small_digits[p >>4 ]; + out[29 + i *3 ] = small_digits[p &15 ]; out[30 + i *3 ] =' ' ; } out[28 + i *3 ] ='\n' ;
drivers/serial/sh-sci.c +2 -4
@@ -119,16 +119,14 @@ }/* Taken from sh-stub.c of GDB 4.18 */ -static const char hexchars[] ="0123456789abcdef" ; -static __inline__char highhex (int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }static __inline__char lowhex (int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
fs/udf/unicode.c +4 -5
@@ -427,7 +427,6 @@int extIndex =0 , newExtIndex =0 , hasExt =0 ;unsigned short valueCRC;uint8_t curr; -const uint8_t hexChar[] ="0123456789ABCDEF" ;if (udfName[0 ] =='.' && (udfLen ==1 || (udfLen ==2 && udfName[1 ] =='.' )))
@@ -500,10 +499,10 @@ newIndex =250 ; newName[newIndex++] =CRC_MARK ; valueCRC =udf_crc (fidName, fidNameLen,0 ); - newName[newIndex++] = hexChar[(valueCRC &0xf000 ) >>12 ]; - newName[newIndex++] = hexChar[(valueCRC &0x0f00 ) >>8 ]; - newName[newIndex++] = hexChar[(valueCRC &0x00f0 ) >>4 ]; - newName[newIndex++] = hexChar[(valueCRC &0x000f )]; + newName[newIndex++] = large_digits[(valueCRC &0xf000 ) >>12 ]; + newName[newIndex++] = large_digits[(valueCRC &0x0f00 ) >>8 ]; + newName[newIndex++] = large_digits[(valueCRC &0x00f0 ) >>4 ]; + newName[newIndex++] = large_digits[(valueCRC &0x000f )];if (hasExt) {
include/linux/kernel.h +2 -0
@@ -86,6 +86,8 @@ })extern struct notifier_block *panic_notifier_list; +extern const char *small_digits; +extern const char *large_digits;extern long (*panic_blink)(long time); NORET_TYPE void panic(const char * fmt, ...) __attribute__ ((NORET_AND format (printf, 1, 2)));
kernel/audit.c +2 -3
@@ -787,7 +787,6 @@int i, avail, new_len;unsigned char *ptr;struct sk_buff *skb; -static const unsigned char *hex ="0123456789ABCDEF" ;BUG_ON (!ab->skb); skb = ab->skb;
@@ -803,8 +802,8 @@ ptr = skb->tail;for (i=0 ; i<len; i++) { - *ptr++ = hex[(buf[i] &0xF0 )>>4 ];/* Upper nibble */ - *ptr++ = hex[buf[i] &0x0F ];/* Lower nibble */ + *ptr++ = large_digits[(buf[i] &0xF0 )>>4 ];/* Upper nibble */ + *ptr++ = large_digits[buf[i] &0x0F ];/* Lower nibble */ } *ptr =0 ;skb_put (skb, len <<1 );/* new string is twice the old string */
lib/vsprintf.c +9 -2
@@ -14,6 +14,9 @@* - changed to provide snprintf and vsnprintf functions * So Feb 1 16:51:32 CET 2004 Juergen Quade <[email protected]> * - scnprintf and vscnprintf +* Oct 5 14:27:25 EDT 2005 Masoud Sharbiani <[email protected]> +* - Made small_digits and large_digits globals and exported them so that +* all drivers dumping hex values can use them from here. */ #include <stdarg.h>
@@ -25,6 +29,12 @@#include <asm/div64.h> +const char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; +EXPORT_SYMBOL (small_digits); + +const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; +EXPORT_SYMBOL (large_digits); +/** * simple_strtoul - convert a string to an unsigned long * @cp: The start of the string
@@ -146,8 +156,6 @@ {char c,sign,tmp[66 ];const char *digits; -static const char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; -static const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;int i; digits = (type &LARGE ) ? large_digits : small_digits;
net/ipv4/arp.c +2 -3
@@ -1291,7 +1291,6 @@ struct neighbour *n) {char hbuffer[HBUFFERLEN ]; -const char hexbuf[] ="0123456789ABCDEF" ;int k, j;char tbuf[16 ];struct net_device *dev = n->dev;
@@ -1305,8 +1304,8 @@ else {#endif for (k =0 , j =0 ; k <HBUFFERLEN -3 && j < dev->addr_len; j++) { - hbuffer[k++] = hexbuf[(n->ha[j] >>4 ) &15 ]; - hbuffer[k++] = hexbuf[n->ha[j] &15 ]; + hbuffer[k++] = large_digits[(n->ha[j] >>4 ) &15 ]; + hbuffer[k++] = large_digits[n->ha[j] &15 ]; hbuffer[k++] =':' ; } hbuffer[--k] =0 ;
net/ipv4/netfilter/ipt_CLUSTERIP.c +2 -3
@@ -502,11 +502,10 @@#define HBUFFERLEN 30char hbuffer[HBUFFERLEN ];int j,k; -const char hexbuf[]="0123456789abcdef" ;for (k=0 , j=0 ; k <HBUFFERLEN -3 && j <ETH_ALEN ; j++) { - hbuffer[k++]=hexbuf[(payload->src_hw[j]>>4 )&15 ]; - hbuffer[k++]=hexbuf[payload->src_hw[j]&15 ]; + hbuffer[k++]=small_digits[(payload->src_hw[j]>>4 )&15 ]; + hbuffer[k++]=small_digits[payload->src_hw[j]&15 ]; hbuffer[k++]=':' ; } hbuffer[--k]='\0' ;
drivers/ide/ide.c +3 -5
@@ -1442,8 +1442,6 @@*/ static int __init match_parm (char *s,const char *keywords[],int vals[],int max_vals) { -static const char *decimal ="0123456789" ; -static const char *hex ="0123456789abcdef" ;int i, n;if (*s++ =='=' ) {
@@ -1463,12 +1461,12 @@* or base16 when prefixed with "0x". * Return a count of how many were found. */ -for (n =0 ; (i =stridx (decimal, *s)) >=0 ;) { +for (n =0 ; (i =stridx (small_digits, *s)) >=0 ;) { vals[n] = i; -while ((i =stridx (decimal, *++s)) >=0 ) +while ((i =stridx (small_digits, *++s)) >=0 ) vals[n] = (vals[n] *10 ) + i;if (*s =='x' && !vals[n]) { -while ((i =stridx (hex, *++s)) >=0 ) +while ((i =stridx (small_digits, *++s)) >=0 ) vals[n] = (vals[n] *0x10 ) + i; }if (++n == max_vals)
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 10 lines · Masoud Sharbiani
Quoted 2 lines · Matthew Wilcox
- Instead of introducing a new lib file and a new header file, how about exporting all this via
vsprintf.cand <linux/kernel.h>?Also done.
Quoted 1 line
- I prefer the longer names 'hexchar' to just 'hex'.
How about
small_digitsandlarge_digitsthat are already there inlib/vsprint.c?
Sounds sane.
arch/cris/arch-v10/kernel/kgdb.c
Quoted 9 lines
Quoted 4 lines
- A lot of these look like open coded versions of using
sprintf(dest, "%x", arg);
- Some seem to be unnecessary implementations of common library functions. eggdb_cris_strtol()could usesimple_strtol()instead.I'll hopefully do this one in a separate patch hopefully tomorrow.
arch/cris/arch-v10/kernel/kgdb.c +0
-0
Please, add "-p" to your diff(1) flags. It'd sometimes make reviewing much easier.
arch/cris/arch-v10/kernel/kgdb.c line 563
Quoted 11 lines
arch/cris/arch-v10/kernel/kgdb.c +2
-2@@ -557,8 +556,8 @@char *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {
simple_strtol()
arch/cris/arch-v32/kernel/kgdb.c line 556
Quoted 13 lines
arch/cris/arch-v32/kernel/kgdb.c +2
-2@@ -550,8 +549,8 @@char *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {/* Unconverted suffix is stored in endptr unless endptr is NULL. */
simple_strtol().
Hmmm... Why do we have multiple copies of kgdb stuff lying around?
Quoted 8 lines
arch/cris/arch-v32/kernel/kgdb.c +1
-1@@ -660,7 +659,7 @@static inline char highhex (int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }
arch/cris/arch-v32/kernel/kgdb.c line 671
Quoted 6 lines
arch/cris/arch-v32/kernel/kgdb.c +1
-1@@ -668,7 +667,7 @@static inline char lowhex (int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }
Possibly worth moving to include/linux/ leaving as static inline. Or removing:
small_digits[x >> 4]; small_digits[x & 0xf];
It isn't hard to guess what the above means. Don't know what is better.
Quoted 22 lines
arch/cris/arch-v32/kernel/kgdb.c +1
-0+ output_buffer[2 ] = small_digits[sigval &0xf ]; output_buffer[3 ] =0 ;break ;arch/ppc/boot/common/misc-common.c +2
-2@@ -280,7 +280,7 @@int i;for (i =7 ; i >=0 ; i--) { - buf[i] ="0123456789ABCDEF" [val &0x0F ]; + buf[i] = small_digits[val &0x0F ]; val >>=4 ; } buf[8 ] ='\0' ;@@ -362,13 +362,13 @@ sign ='-' ; val = -val; } - length =_cvt (val, buf,10 ,"0123456789" ); + length =_cvt (val, buf,10 , decimal);break ;
arch/ppc/boot/common/misc-common.c line 374
Quoted 10 lines
arch/ppc/boot/common/misc-common.c +2
-2case 'x' : - length =_cvt (val, buf,16 ,"0123456789abcdef" ); + length =_cvt (val, buf,16 , hex);break ;case 'X' : - length =_cvt (val, buf,16 ,"0123456789ABCDEF" ); + length =_cvt (val, buf,16 ,HEX );break ; } cp = buf;
Both _vprintk() and _cvt should die.
drivers/net/sk98lin/skge.c line 4857
Quoted 5 lines
drivers/net/sk98lin/skge.c +1
-1@@ -4858,7 +4857,7 @@ -char HEXCHAR [] ="0123456789ABCDEF" ; +char large_digits[] ="0123456789ABCDEF" ;
Just remove it.
drivers/pnp/pnpbios/rsparser.c line 486
Quoted 11 lines
drivers/pnp/pnpbios/rsparser.c +0
-2@@ -481,8 +481,6 @@void pnpid32_to_pnpid (u32 id,char *str) { -const char *hex ="0123456789abcdef" ; - id =be32_to_cpu (id); str[0 ] =CHAR (id,26 ); str[1 ] =CHAR (id,21 );
This won't fly. See macros several lines above. Compile-test before sending.
drivers/scsi/ibmmca.c line 1012
Quoted 10 lines
drivers/scsi/ibmmca.c +0
-1@@ -1007,7 +1007,6 @@/* interpreter for logical device numbers (ldn) */ static char *ti_l (int val) { -const char hex[16 ] ="0123456789abcdef" ;static char answer[2 ]; answer[1 ] = (char ) (0x0 );
Ditto.
lib/vsprintf.c line 19
Quoted 9 lines
lib/vsprintf.c +3
-0@@ -14,6 +14,9 @@* - changed to provide snprintf and vsnprintf functions * So Feb 1 16:51:32 CET 2004 Juergen Quade <[email protected]> * - scnprintf and vscnprintf +* Oct 5 14:27:25 EDT 2005 Masoud Sharbiani <[email protected]> +* - Made small_digits and large_digits globals and exported them so that +* all drivers dumping hex values can use them from here.
No need. It's git's job to maintain changelogs.
lib/vsprintf.c line 36
Quoted 5 lines
lib/vsprintf.c +5
-0+const char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; +EXPORT_SYMBOL (small_digits); + +const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; +EXPORT_SYMBOL (large_digits);
I guess many people from linux-kernel will shoot us for exporting _this_.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 8 lines · Alexey Dobriyan
lib/vsprintf.c line 36
Quoted 5 lines
lib/vsprintf.c +5
-0+const char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; +EXPORT_SYMBOL (small_digits); + +const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; +EXPORT_SYMBOL (large_digits);I guess many people from linux-kernel will shoot us for exporting _this_.
I don't see why. If we want to use it from modules, we need to export it.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 17 lines · Alexey Dobriyan
arch/cris/arch-v10/kernel/kgdb.c
Quoted 3 lines · Masoud Sharbiani
On Wed, Oct 05, 2005 at 11:25:33AM -0600, Matthew Wilcox wrote:
arch/cris/arch-v10/kernel/kgdb.c +0
-0Please, add "-p" to your diff(1) flags. It'd sometimes make reviewing much easier.
Quoted 9 lines
arch/cris/arch-v10/kernel/kgdb.c +2
-2@@ -557,8 +556,8 @@char *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);
Quoted 4 lines
arch/cris/arch-v10/kernel/kgdb.c line 563
Quoted 2 lines
arch/cris/arch-v10/kernel/kgdb.c +0
-0if (endptr) {
simple_strtol()
I think the reason that they have reimplemented these is that they want to have a separate function to avoid single stepping into the library functions and thus failing the kgdb. Same thing goes for reimplementations of strlen and other library functions in the same file.
cheers,
Masoud
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] hexdigits definition consolidation [RESEND3]
In reply to Masoud SharbianiHello,
This is 3rd edition of hexdigits consolidation patch.
I've refrained from modifying kgdb files (cris arch) and boot-misc.c (ppc arch) since they may be subject to space or other technical limitions.
cheers,
Masoud
arch/cris/arch-v10/kernel/kgdb.c +2 -3
@@ -415,7 +415,6 @@ extern unsigned char executing_task;#define RUNLENMAX 64/* Definition of all valid hexadecimal characters */ -static const char hexchars[] ="0123456789abcdef" ;/* The inbound/outbound buffers used in packet I/O */ static char remcomInBuffer[BUFMAX ];
@@ -557,8 +556,8 @@ gdb_cris_strtol (const char *s, char **echar *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {
arch/cris/arch-v32/kernel/kgdb.c +4 -5
@@ -465,7 +465,6 @@ void breakpoint(void);#define RUNLENMAX 64/* Definition of all valid hexadecimal characters */ -static const char hexchars[] ="0123456789abcdef" ;/* The inbound/outbound buffers used in packet I/O */ static char input_buffer[BUFMAX ];
@@ -550,8 +549,8 @@ gdb_cris_strtol(const char *s, char **enchar *sd;int x =0 ; -for (s1 = (char *)s; (sd =gdb_cris_memchr (hexchars, *s1, base)) !=NULL ; ++s1) - x = x * base + (sd - hexchars); +for (s1 = (char *)s; (sd =gdb_cris_memchr (small_digits, *s1, base)) !=NULL ; ++s1) + x = x * base + (sd - small_digits);if (endptr) {/* Unconverted suffix is stored in endptr unless endptr is NULL. */
@@ -660,7 +659,7 @@ read_register(char regno, unsigned int *static inline char highhex (int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
@@ -668,7 +667,7 @@ highhex(int x)static inline char lowhex (int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }/* Returns the integer equivalent of a hexadecimal character. */
arch/frv/kernel/gdb-stub.c +50 -52
182 lines not on this page · raw message
arch/mips/au1000/common/puts.c +2 -3
@@ -39,7 +39,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned long *const com1 = (unsigned long *)SERIAL_BASE ;
@@ -124,7 +123,7 @@ put64(uint64_t ul)do { cnt--; ch = (unsigned char )(ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -140,6 +139,6 @@ put32(unsigned u)do { cnt--; ch = (unsigned char )(u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/galileo-boards/ev96100/puts.c +2 -3
@@ -21,7 +21,6 @@#define TIMEOUT 0xffff#undef SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned char *const com1 = (unsigned char *)SERIAL_BASE ;
@@ -118,7 +117,7 @@ void put64(uint64_t ul)do { cnt--; ch = (unsigned char ) (ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -133,6 +132,6 @@ void put32(unsigned u)do { cnt--; ch = (unsigned char ) (u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/ite-boards/generic/puts.c +2 -3
@@ -38,7 +38,6 @@#define TIMEOUT 0xffff#undef SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ;static volatile unsigned char *const com1 = (unsigned char *)SERIAL_BASE ;
@@ -119,7 +118,7 @@ void put64(uint64_t ul)do { cnt--; ch = (unsigned char ) (ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -134,6 +133,6 @@ void put32(unsigned u)do { cnt--; ch = (unsigned char ) (u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/jmr3927/common/puts.c +2 -4
@@ -40,8 +40,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ; -#ifdef SLOW_DOWN #define slow_down () { int k; for (k=0; k<10000; k++); }#else
@@ -147,7 +145,7 @@ put64(uint64_t ul)do { cnt--; ch = (unsigned char )(ul >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
@@ -163,6 +161,6 @@ put32(unsigned u)do { cnt--; ch = (unsigned char )(u >> cnt *4 ) &0x0F ; -putch (digits[ch]); +putch (small_digits[ch]); }while (cnt >0 ); }
arch/mips/jmr3927/rbhma3100/kgdb_io.c +0 -2
@@ -39,8 +39,6 @@#define TIMEOUT 0xffffff#define SLOW_DOWN -static const char digits[16 ] ="0123456789abcdef" ; -#ifdef SLOW_DOWN #define slow_down () { int k; for (k=0; k<10000; k++); }#else
arch/mips/kernel/gdb-stub.c +14 -15
@@ -189,7 +189,6 @@ static char input_buffer[BUFMAX];static char output_buffer[BUFMAX ];static int initialized;/* !0 means we've been initialized */ static int kgdb_started; -static const char hexchars[]="0123456789abcdef" ;/* Used to prevent crashes in memory access. Note that they'll crash anyway if we haven't set up fault handlers yet... */
@@ -305,8 +304,8 @@ static void putpacket(char *buffer) }putDebugChar ('#' ); -putDebugChar (hexchars[checksum >>4 ]); -putDebugChar (hexchars[checksum &0xf ]); +putDebugChar (small_digits[checksum >>4 ]); +putDebugChar (small_digits[checksum &0xf ]); }while ((getDebugChar () &0x7f ) !='+' );
@@ -327,8 +326,8 @@ static unsigned char *mem2hex(char *mem,while (count-- >0 ) {if (kgdb_read_byte (mem++, &ch) !=0 )return 0 ; - *buf++ = hexchars[ch >>4 ]; - *buf++ = hexchars[ch &0xf ]; + *buf++ = small_digits[ch >>4 ]; + *buf++ = small_digits[ch &0xf ]; } *buf =0 ;
@@ -748,14 +747,14 @@ void handle_exception (struct gdb_regs ** Send trap type (converted to signal) */ *ptr++ ='T' ; - *ptr++ = hexchars[sigval >>4 ]; - *ptr++ = hexchars[sigval &0xf ]; + *ptr++ = small_digits[sigval >>4 ]; + *ptr++ = small_digits[sigval &0xf ];/* * Send Error PC */ - *ptr++ = hexchars[REG_EPC >>4 ]; - *ptr++ = hexchars[REG_EPC &0xf ]; + *ptr++ = small_digits[REG_EPC >>4 ]; + *ptr++ = small_digits[REG_EPC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->cp0_epc, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -763,8 +762,8 @@ void handle_exception (struct gdb_regs */* * Send frame pointer */ - *ptr++ = hexchars[REG_FP >>4 ]; - *ptr++ = hexchars[REG_FP &0xf ]; + *ptr++ = small_digits[REG_FP >>4 ]; + *ptr++ = small_digits[REG_FP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->reg30, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -772,8 +771,8 @@ void handle_exception (struct gdb_regs */* * Send stack pointer */ - *ptr++ = hexchars[REG_SP >>4 ]; - *ptr++ = hexchars[REG_SP &0xf ]; + *ptr++ = small_digits[REG_SP >>4 ]; + *ptr++ = small_digits[REG_SP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®s->reg29, ptr,sizeof (long ),0 ); *ptr++ =';' ;
@@ -792,8 +791,8 @@ void handle_exception (struct gdb_regs * {case '?' : output_buffer[0 ] ='S' ; - output_buffer[1 ] = hexchars[sigval >>4 ]; - output_buffer[2 ] = hexchars[sigval &0xf ]; + output_buffer[1 ] = small_digits[sigval >>4 ]; + output_buffer[2 ] = small_digits[sigval &0xf ]; output_buffer[3 ] =0 ;break ;
arch/ppc/boot/common/misc-common.c +5 -5
@@ -280,7 +280,7 @@ puthex(unsigned long val)int i;for (i =7 ; i >=0 ; i--) { - buf[i] ="0123456789ABCDEF" [val &0x0F ]; + buf[i] = large_digits[val &0x0F ]; val >>=4 ; } buf[8 ] ='\0' ;
@@ -362,13 +362,13 @@ _vprintk(void(*putc)(const char), const sign ='-' ; val = -val; } - length =_cvt (val, buf,10 ,"0123456789" ); + length =_cvt (val, buf,10 , small_digits);break ;case 'x' : - length =_cvt (val, buf,16 ,"0123456789abcdef" ); + length =_cvt (val, buf,16 , small_digits);break ;case 'X' : - length =_cvt (val, buf,16 ,"0123456789ABCDEF" ); + length =_cvt (val, buf,16 , large_digits);break ; } cp = buf;
@@ -450,7 +450,7 @@ _cvt(unsigned long val, char *buf, long }else while (val) { - *cp++ = digits[val % radix]; + *cp++ = small_digits[val % radix]; val /= radix; }while (cp != temp)
arch/ppc/kernel/ppc-stub.c +24 -25
90 lines not on this page · raw message
arch/ppc/kernel/process.c +1 -1
@@ -695,7 +695,7 @@ void puthex(unsigned long val)int i;for (i =7 ; i >=0 ; i--) { - buf[i] ="0123456789ABCDEF" [val &0x0F ]; + buf[i] = large_digits[val &0x0F ]; val >>=4 ; } buf[8 ] ='\0' ;
arch/ppc/platforms/apus_setup.c +1 -2
@@ -627,10 +627,9 @@ int __debug_serinit( void )void __debug_print_hex (unsigned long x) {int i; -char hexchars[] ="0123456789ABCDEF" ;for (i =0 ; i <8 ; i++) { -__debug_ser_out (hexchars[(x >>28 ) &15 ]); +__debug_ser_out (large_digits[(x >>28 ) &15 ]); x <<=4 ; }__debug_ser_out ('\n' );
arch/ppc/platforms/residual.c +4 -5
@@ -770,15 +770,14 @@ static int __init same_DevID(unsigned shunsigned short Number, char * str) { -static unsigned const char hexdigit[]="0123456789ABCDEF" ; if (strlen(str)!=7) return 0; if ( ( ((vendor>>10)&0x1f)+'A'-1 == str[0]) && ( ((vendor>>5)&0x1f)+'A'-1 == str[1]) && ( (vendor&0x1f)+'A'-1 == str[2]) && - (hexdigit[(Number>>12 )&0x0f ] == str[3 ]) && - (hexdigit[(Number>>8 )&0x0f ] == str[4 ]) && - (hexdigit[(Number>>4 )&0x0f ] == str[5 ]) && - (hexdigit[Number&0x0f ] == str[6 ]) )return 1 ; + (large_digits[(Number>>12 )&0x0f ] == str[3 ]) && + (large_digits[(Number>>8 )&0x0f ] == str[4 ]) && + (large_digits[(Number>>4 )&0x0f ] == str[5 ]) && + (large_digits[Number&0x0f] == str[6]) ) return 1;return 0 ; }
arch/ppc/syslib/btext.c +8 -9
@@ -392,18 +392,17 @@ btext_drawstring(const char *c) void BTEXTbtext_drawhex (unsigned long v) { -static char hex_table[] ="0123456789abcdef" ;if (!boot_text_mapped)return ; -btext_drawchar (hex_table[(v >>28 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>24 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>20 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>16 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>12 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>8 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>4 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>0 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>28 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>24 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>20 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>16 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>12 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>8 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>4 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>0 ) &0x0000000FUL ]);btext_drawchar (' ' ); }
arch/ppc64/kernel/btext.c +16 -18
@@ -278,26 +278,24 @@ void btext_drawstring(const char *c)void btext_drawhex (unsigned long v) { -char *hex_table ="0123456789abcdef" ; -if (!boot_text_mapped)return ; -btext_drawchar (hex_table[(v >>60 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>56 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>52 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>48 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>44 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>40 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>36 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>32 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>28 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>24 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>20 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>16 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>12 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>8 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>4 ) &0x0000000FUL ]); -btext_drawchar (hex_table[(v >>0 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>60 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>56 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>52 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>48 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>44 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>40 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>36 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>32 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>28 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>24 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>20 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>16 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>12 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>8 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>4 ) &0x0000000FUL ]); +btext_drawchar (small_digits[(v >>0 ) &0x0000000FUL ]);btext_drawchar (' ' ); }
arch/ppc64/kernel/mf.c +4 -4
@@ -643,10 +643,10 @@ void mf_display_progress(u16 value) 72); src[6 ] = value >>8 ; src[7 ] = value &255 ; - src[44 ] ="0123456789ABCDEF" [(value >>12 ) &15 ]; - src[45 ] ="0123456789ABCDEF" [(value >>8 ) &15 ]; - src[46 ] ="0123456789ABCDEF" [(value >>4 ) &15 ]; - src[47 ] ="0123456789ABCDEF" [value &15 ]; + src[44 ] = large_digits[(value >>12 ) &15 ]; + src[45 ] = large_digits[(value >>8 ) &15 ]; + src[46 ] = large_digits[(value >>4 ) &15 ]; + src[47 ] = large_digits[value &15 ];dma_and_signal_ce_msg (ce,NULL , src,sizeof (src),9 *64 *1024 ); }
arch/sh/kernel/kgdb_stub.c +4 -5
@@ -240,7 +240,6 @@ static jmp_buf rem_com_env;/* Misc static */ static int stepped_address;static short stepped_opcode; -static const char hexchars[] ="0123456789abcdef" ;static char in_buffer[BUFMAX ];static char out_buffer[OUTBUFMAX ];
@@ -268,13 +267,13 @@ static inline void ctrl_outl(const unsig/* Get high hex bits */ static char highhex (const int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }/* Get low hex bits */ static char lowhex (const int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }/* Convert ch to hex */
@@ -367,8 +366,8 @@ static char *ebin_to_mem(const char *buf/* Pack a hex byte */ static char *pack_hex_byte (char *pkt,int byte) { - *pkt++ = hexchars[(byte >>4 ) &0xf ]; - *pkt++ = hexchars[(byte &0xf )]; + *pkt++ = small_digits[(byte >>4 ) &0xf ]; + *pkt++ = small_digits[(byte &0xf )];return pkt; }
arch/sparc/kernel/sparc-stub.c +18 -20
@@ -127,8 +127,6 @@ extern char getDebugChar(void); /* reastatic int initialized;/* !0 means we've been initialized */ -static const char hexchars[]="0123456789abcdef" ; -#define NUMREGS 72/* Number of bytes of registers. */
@@ -298,8 +296,8 @@ putpacket(unsigned char *buffer) }putDebugChar ('#' ); -putDebugChar (hexchars[checksum >>4 ]); -putDebugChar (hexchars[checksum &0xf ]); +putDebugChar (small_digits[checksum >>4 ]); +putDebugChar (small_digits[checksum &0xf ]); recv =getDebugChar (); }while ((recv &0x7f ) !='+' ); }
@@ -337,8 +335,8 @@ mem2hex(char *mem, char *buf, int count) ".word 1b, 2b\n\t" ".text\n" : "=r" (mem), "=r" (ch) : "0" (mem)); - *buf++ = hexchars[ch >>4 ]; - *buf++ = hexchars[ch &0xf ]; + *buf++ = small_digits[ch >>4 ]; + *buf++ = small_digits[ch &0xf ]; } *buf =0 ;
@@ -527,35 +525,35 @@ handle_exception (unsigned long *registe ptr = remcomOutBuffer; *ptr++ ='T' ; - *ptr++ = hexchars[sigval >>4 ]; - *ptr++ = hexchars[sigval &0xf ]; + *ptr++ = small_digits[sigval >>4 ]; + *ptr++ = small_digits[sigval &0xf ]; - *ptr++ = hexchars[PC >>4 ]; - *ptr++ = hexchars[PC &0xf ]; + *ptr++ = small_digits[PC >>4 ]; + *ptr++ = small_digits[PC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[PC ], ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[FP >>4 ]; - *ptr++ = hexchars[FP &0xf ]; + *ptr++ = small_digits[FP >>4 ]; + *ptr++ = small_digits[FP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *) (sp +8 +6 ), ptr,4 );/* FP */ *ptr++ =';' ; - *ptr++ = hexchars[SP >>4 ]; - *ptr++ = hexchars[SP &0xf ]; + *ptr++ = small_digits[SP >>4 ]; + *ptr++ = small_digits[SP &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)&sp, ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[NPC >>4 ]; - *ptr++ = hexchars[NPC &0xf ]; + *ptr++ = small_digits[NPC >>4 ]; + *ptr++ = small_digits[NPC &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[NPC ], ptr,4 ); *ptr++ =';' ; - *ptr++ = hexchars[O7 >>4 ]; - *ptr++ = hexchars[O7 &0xf ]; + *ptr++ = small_digits[O7 >>4 ]; + *ptr++ = small_digits[O7 &0xf ]; *ptr++ =':' ; ptr =mem2hex ((char *)®isters[O7 ], ptr,4 ); *ptr++ =';' ;
@@ -577,8 +575,8 @@ handle_exception (unsigned long *registeswitch (remcomInBuffer[0 ]) {case '?' : remcomOutBuffer[0 ] ='S' ; - remcomOutBuffer[1 ] = hexchars[sigval >>4 ]; - remcomOutBuffer[2 ] = hexchars[sigval &0xf ]; + remcomOutBuffer[1 ] = small_digits[sigval >>4 ]; + remcomOutBuffer[2 ] = small_digits[sigval &0xf ]; remcomOutBuffer[3 ] =0 ;break ;
drivers/ide/ide.c +3 -5
@@ -1442,8 +1442,6 @@ static int __init stridx (const char *s,*/ static int __init match_parm (char *s,const char *keywords[],int vals[],int max_vals) { -static const char *decimal ="0123456789" ; -static const char *hex ="0123456789abcdef" ;int i, n;if (*s++ =='=' ) {
@@ -1463,12 +1461,12 @@ static int __init match_parm (char *s, c* or base16 when prefixed with "0x". * Return a count of how many were found. */ -for (n =0 ; (i =stridx (decimal, *s)) >=0 ;) { +for (n =0 ; (i =stridx (small_digits, *s)) >=0 ;) { vals[n] = i; -while ((i =stridx (decimal, *++s)) >=0 ) +while ((i =stridx (small_digits, *++s)) >=0 ) vals[n] = (vals[n] *10 ) + i;if (*s =='x' && !vals[n]) { -while ((i =stridx (hex, *++s)) >=0 ) +while ((i =stridx (small_digits, *++s)) >=0 ) vals[n] = (vals[n] *0x10 ) + i; }if (++n == max_vals)
drivers/isdn/isdnloop/isdnloop.c +1 -1
@@ -1297,7 +1297,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop c->parm.num[0] ? "N" : "ALL", c->parm.num); }else sprintf (cbuf,"%02d;EAZ%s\n" , (int ) a, - c->parm.num[0 ] ? c->parm.num : (u_char *)"0123456789" ); + c->parm.num[0 ] ? c->parm.num : decimal); i =isdnloop_writecmd (cbuf,strlen (cbuf),0 , card); }break ;
drivers/net/irda/ma600.c +3 -7
@@ -54,10 +54,6 @@ func}#endif -/* convert hex value to ascii hex */ -static const char hexTbl[] ="0123456789ABCDEF" ; - -static void ma600_open (dongle_t *self,struct qos_info *qos);static void ma600_close (dongle_t *self);static int ma600_change_speed (struct irda_task *task);
@@ -243,10 +239,10 @@ static int ma600_change_speed(struct ird/* if control byte != echo, I don't know what to do */ printk (KERN_WARNING "%s() control byte written != read!\n" , __FUNCTION__);printk (KERN_WARNING "control byte = 0x%c%c\n" , - hexTbl[(byte>>4 )&0x0f ], hexTbl[byte&0x0f ]); + large_digits[(byte>>4 )&0x0f ], large_digits[byte&0x0f ]);printk (KERN_WARNING "byte echo = 0x%c%c\n" , - hexTbl[(byte_echo>>4 ) &0x0f ], - hexTbl[byte_echo &0x0f ]); + large_digits[(byte_echo>>4 ) &0x0f ], + large_digits[byte_echo &0x0f ]); #ifndef NDEBUG }else {IRDA_DEBUG (2 ,"%s() control byte write read OK\n" , __FUNCTION__);
drivers/net/sk98lin/skge.c +10 -12
@@ -4810,7 +4810,6 @@ register int i;int haddr, addr;char hex_buffer[180 ];char asc_buffer[180 ]; -char HEXCHAR [] ="0123456789ABCDEF" ; addr =0 ; haddr =0 ;
@@ -4823,9 +4822,9 @@ char HEXCHAR[] = "0123456789ABCDEF"; asc_buffer[addr] ='.' ; addr++; asc_buffer[addr] =0 ; - hex_buffer[haddr] =HEXCHAR [(*p &0xf0 ) >>4 ]; + hex_buffer[haddr] = large_digits[(*p &0xf0 ) >>4 ]; haddr++; - hex_buffer[haddr] =HEXCHAR [*p &0x0f ]; + hex_buffer[haddr] = large_digits[*p &0x0f ]; haddr++; hex_buffer[haddr] =' ' ; haddr++;
@@ -4858,7 +4857,6 @@ register int i;int haddr, addr;char hex_buffer[180 ];char asc_buffer[180 ]; -char HEXCHAR [] ="0123456789ABCDEF" ;long *p;int l;
@@ -4869,21 +4867,21 @@ int l; p = (long *) pc;for (i=0 ; i < size; ) { l = (long ) *p; - hex_buffer[haddr] =HEXCHAR [(l >>28 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>28 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>24 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>24 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>20 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>20 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>16 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>16 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>12 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>12 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>8 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>8 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [(l >>4 ) &0xf ]; + hex_buffer[haddr] = large_digits[(l >>4 ) &0xf ]; haddr++; - hex_buffer[haddr] =HEXCHAR [l &0x0f ]; + hex_buffer[haddr] = large_digits[l &0x0f ]; haddr++; hex_buffer[haddr] =' ' ; haddr++;
drivers/net/skfp/smt.c +1 -1
@@ -1731,7 +1731,7 @@ void fddi_send_antc(struct s_smc *smc, s#endif #ifdef DEBUG -#define hextoasc (x) "0123456789abcdef"[x] +#define hextoasc (x) small_digits[x]char *addr_to_string (struct fddi_addr *addr) {
drivers/net/wireless/strip.c +12 -14
@@ -404,8 +404,6 @@ static const StringDescriptor CommandStr (S)->battery_voltage.c[0] && \ memcmp(&(S)->true_dev_addr, zero_address.c, sizeof(zero_address))) -static const char hextable[16 ] ="0123456789ABCDEF" ; -static const MetricomAddress zero_address;static const MetricomAddress broadcast_address = { {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF } };
@@ -1292,13 +1290,13 @@ static __u8 *add_checksum(__u8 * buffer,__u8 *p = buffer;while (p < end) sum += *p++; - end[3 ] = hextable[sum &0xF ]; + end[3 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[2 ] = hextable[sum &0xF ]; + end[2 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[1 ] = hextable[sum &0xF ]; + end[1 ] = large_digits[sum &0xF ]; sum >>=4 ; - end[0 ] = hextable[sum &0xF ]; + end[0 ] = large_digits[sum &0xF ];return (end +4 ); }
@@ -1379,15 +1377,15 @@ static unsigned char *strip_make_packet( *ptr++ =0x0D ; *ptr++ ='*' ; - *ptr++ = hextable[haddr.c[2 ] >>4 ]; - *ptr++ = hextable[haddr.c[2 ] &0xF ]; - *ptr++ = hextable[haddr.c[3 ] >>4 ]; - *ptr++ = hextable[haddr.c[3 ] &0xF ]; + *ptr++ = large_digits[haddr.c[2 ] >>4 ]; + *ptr++ = large_digits[haddr.c[2 ] &0xF ]; + *ptr++ = large_digits[haddr.c[3 ] >>4 ]; + *ptr++ = large_digits[haddr.c[3 ] &0xF ]; *ptr++ ='-' ; - *ptr++ = hextable[haddr.c[4 ] >>4 ]; - *ptr++ = hextable[haddr.c[4 ] &0xF ]; - *ptr++ = hextable[haddr.c[5 ] >>4 ]; - *ptr++ = hextable[haddr.c[5 ] &0xF ]; + *ptr++ = large_digits[haddr.c[4 ] >>4 ]; + *ptr++ = large_digits[haddr.c[4 ] &0xF ]; + *ptr++ = large_digits[haddr.c[5 ] >>4 ]; + *ptr++ = large_digits[haddr.c[5 ] &0xF ]; *ptr++ ='*' ; *ptr++ = key.c[0 ]; *ptr++ = key.c[1 ];
drivers/pnp/pnpbios/rsparser.c +1 -3
@@ -475,14 +475,12 @@ pnpbios_parse_resource_option_data(unsig* Compatible Device IDs */ -#define HEX (id,a) hex[((id)>>a) & 15] +#define HEX (id,a) small_digits[((id)>>a) & 15]#define CHAR (id,a) (0x40 + (((id)>>a) & 31))// void pnpid32_to_pnpid (u32 id,char *str) { -const char *hex ="0123456789abcdef" ; - id =be32_to_cpu (id); str[0 ] =CHAR (id,26 ); str[1 ] =CHAR (id,21 );
drivers/scsi/ibmmca.c +1 -2
@@ -1007,12 +1007,11 @@ static char *ti_p(int dev)/* interpreter for logical device numbers (ldn) */ static char *ti_l (int val) { -const char hex[16 ] ="0123456789abcdef" ;static char answer[2 ]; answer[1 ] = (char ) (0x0 );if (val <=MAX_LOG_DEV ) - answer[0 ] = hex[val]; + answer[0 ] = small_digits[val];else answer[0 ] ='-' ;return (char *) &answer;
drivers/scsi/ultrastor.c +2 -2
@@ -869,8 +869,8 @@ static int ultrastor_abort(Scsi_Cmnd *SCfor (i =0 ; i <16 ; i++) {unsigned char p =inb (port0 + i); - out[28 + i *3 ] ="0123456789abcdef" [p >>4 ]; - out[29 + i *3 ] ="0123456789abcdef" [p &15 ]; + out[28 + i *3 ] = small_digits[p >>4 ]; + out[29 + i *3 ] = small_digits[p &15 ]; out[30 + i *3 ] =' ' ; } out[28 + i *3 ] ='\n' ;
drivers/serial/sh-sci.c +2 -4
@@ -119,16 +119,14 @@ static int get_char(struct uart_port *po }/* Taken from sh-stub.c of GDB 4.18 */ -static const char hexchars[] ="0123456789abcdef" ; -static __inline__char highhex (int x) { -return hexchars[(x >>4 ) &0xf ]; +return small_digits[(x >>4 ) &0xf ]; }static __inline__char lowhex (int x) { -return hexchars[x &0xf ]; +return small_digits[x &0xf ]; }#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
fs/udf/unicode.c +4 -5
@@ -427,7 +427,6 @@ static int udf_translate_to_linux(uint8_int extIndex =0 , newExtIndex =0 , hasExt =0 ;unsigned short valueCRC;uint8_t curr; -const uint8_t hexChar[] ="0123456789ABCDEF" ;if (udfName[0 ] =='.' && (udfLen ==1 || (udfLen ==2 && udfName[1 ] =='.' )))
@@ -500,10 +499,10 @@ static int udf_translate_to_linux(uint8_ newIndex =250 ; newName[newIndex++] =CRC_MARK ; valueCRC =udf_crc (fidName, fidNameLen,0 ); - newName[newIndex++] = hexChar[(valueCRC &0xf000 ) >>12 ]; - newName[newIndex++] = hexChar[(valueCRC &0x0f00 ) >>8 ]; - newName[newIndex++] = hexChar[(valueCRC &0x00f0 ) >>4 ]; - newName[newIndex++] = hexChar[(valueCRC &0x000f )]; + newName[newIndex++] = large_digits[(valueCRC &0xf000 ) >>12 ]; + newName[newIndex++] = large_digits[(valueCRC &0x0f00 ) >>8 ]; + newName[newIndex++] = large_digits[(valueCRC &0x00f0 ) >>4 ]; + newName[newIndex++] = large_digits[(valueCRC &0x000f )];if (hasExt) {
include/linux/kernel.h +2 -0
@@ -86,6 +86,8 @@ extern int cond_resched(void); })extern struct notifier_block *panic_notifier_list; +extern const unsigned char small_digits[]; +extern const unsigned char large_digits[];extern long (*panic_blink)(long time); NORET_TYPE void panic(const char * fmt, ...) __attribute__ ((NORET_AND format (printf, 1, 2)));
kernel/audit.c +2 -3
@@ -787,7 +787,6 @@ void audit_log_hex(struct audit_buffer *int i, avail, new_len;unsigned char *ptr;struct sk_buff *skb; -static const unsigned char *hex ="0123456789ABCDEF" ;BUG_ON (!ab->skb); skb = ab->skb;
@@ -803,8 +802,8 @@ void audit_log_hex(struct audit_buffer * ptr = skb->tail;for (i=0 ; i<len; i++) { - *ptr++ = hex[(buf[i] &0xF0 )>>4 ];/* Upper nibble */ - *ptr++ = hex[buf[i] &0x0F ];/* Lower nibble */ + *ptr++ = large_digits[(buf[i] &0xF0 )>>4 ];/* Upper nibble */ + *ptr++ = large_digits[buf[i] &0x0F ];/* Lower nibble */ } *ptr =0 ;skb_put (skb, len <<1 );/* new string is twice the old string */
lib/vsprintf.c +6 -2
@@ -25,6 +25,12 @@#include <asm/div64.h> +const unsigned char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; +EXPORT_SYMBOL (small_digits); + +const unsigned char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; +EXPORT_SYMBOL (large_digits); +/** * simple_strtoul - convert a string to an unsigned long * @cp: The start of the string
@@ -146,8 +152,6 @@ static char * number(char * buf, char * {char c,sign,tmp[66 ];const char *digits; -static const char small_digits[] ="0123456789abcdefghijklmnopqrstuvwxyz" ; -static const char large_digits[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;int i; digits = (type &LARGE ) ? large_digits : small_digits;
net/ipv4/arp.c +2 -3
@@ -1291,7 +1291,6 @@ static void arp_format_neigh_entry(struc struct neighbour *n) {char hbuffer[HBUFFERLEN ]; -const char hexbuf[] ="0123456789ABCDEF" ;int k, j;char tbuf[16 ];struct net_device *dev = n->dev;
@@ -1305,8 +1304,8 @@ static void arp_format_neigh_entry(struc else {#endif for (k =0 , j =0 ; k <HBUFFERLEN -3 && j < dev->addr_len; j++) { - hbuffer[k++] = hexbuf[(n->ha[j] >>4 ) &15 ]; - hbuffer[k++] = hexbuf[n->ha[j] &15 ]; + hbuffer[k++] = large_digits[(n->ha[j] >>4 ) &15 ]; + hbuffer[k++] = large_digits[n->ha[j] &15 ]; hbuffer[k++] =':' ; } hbuffer[--k] =0 ;
net/ipv4/netfilter/ipt_CLUSTERIP.c +2 -3
@@ -502,11 +502,10 @@ static void arp_print(struct arp_payload#define HBUFFERLEN 30char hbuffer[HBUFFERLEN ];int j,k; -const char hexbuf[]="0123456789abcdef" ;for (k=0 , j=0 ; k <HBUFFERLEN -3 && j <ETH_ALEN ; j++) { - hbuffer[k++]=hexbuf[(payload->src_hw[j]>>4 )&15 ]; - hbuffer[k++]=hexbuf[payload->src_hw[j]&15 ]; + hbuffer[k++]=small_digits[(payload->src_hw[j]>>4 )&15 ]; + hbuffer[k++]=small_digits[payload->src_hw[j]&15 ]; hbuffer[k++]=':' ; } hbuffer[--k]='\0' ;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors