Skip to content

Commit f7912de

Browse files
committed
Fix warnings from CLang-tidy
1 parent 2d075a3 commit f7912de

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

test/src/itoa.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#include <string.h>
20-
2119
#ifdef __cplusplus
2220
extern "C" {
2321
#endif
@@ -26,19 +24,19 @@ char* ltoa( long value, char *string, int radix )
2624
{
2725
char tmp[33];
2826
char *tp = tmp;
29-
long i;
27+
unsigned long i;
3028
unsigned long v;
3129
int sign;
3230
char *sp;
3331

34-
if ( string == NULL )
32+
if ( string == nullptr )
3533
{
36-
return 0 ;
34+
return nullptr ;
3735
}
3836

3937
if (radix > 36 || radix <= 1)
4038
{
41-
return 0 ;
39+
return nullptr ;
4240
}
4341

4442
sign = (radix == 10 && value < 0);
@@ -56,9 +54,9 @@ char* ltoa( long value, char *string, int radix )
5654
i = v % radix;
5755
v = v / radix;
5856
if (i < 10)
59-
*tp++ = i+'0';
57+
*tp++ = static_cast<char>(i+'0');
6058
else
61-
*tp++ = i + 'a' - 10;
59+
*tp++ = static_cast<char>(i + 'a' - 10);
6260
}
6361

6462
sp = string;
@@ -76,28 +74,28 @@ char* ultoa( unsigned long value, char *string, int radix )
7674
{
7775
char tmp[33];
7876
char *tp = tmp;
79-
long i;
77+
unsigned long i;
8078
unsigned long v = value;
8179
char *sp;
8280

83-
if ( string == NULL )
81+
if ( string == nullptr )
8482
{
85-
return 0;
83+
return nullptr;
8684
}
8785

8886
if (radix > 36 || radix <= 1)
8987
{
90-
return 0;
88+
return nullptr;
9189
}
9290

9391
while (v || tp == tmp)
9492
{
9593
i = v % radix;
9694
v = v / radix;
9795
if (i < 10)
98-
*tp++ = i+'0';
96+
*tp++ = static_cast<char>(i+'0');
9997
else
100-
*tp++ = i + 'a' - 10;
98+
*tp++ = static_cast<char>(i + 'a' - 10);
10199
}
102100

103101
sp = string;

0 commit comments

Comments
 (0)