Skip to content

Commit 9f06bb3

Browse files
authored
Drop remaining usage of u_char in favour of standard C99 uint8_t (#8611)
Plus minor drive-by fixes
1 parent 59b4fdb commit 9f06bb3

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

ext/snmp/snmp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ static bool netsnmp_session_init(php_snmp_session **session_p, int version, zend
913913
session->securityNameLen = ZSTR_LEN(community);
914914
} else {
915915
session->authenticator = NULL;
916-
session->community = (u_char *)estrdup(ZSTR_VAL(community));
916+
session->community = (uint8_t *)estrdup(ZSTR_VAL(community));
917917
session->community_len = ZSTR_LEN(community);
918918
}
919919

@@ -1035,7 +1035,7 @@ static bool netsnmp_session_gen_auth_key(struct snmp_session *s, zend_string *pa
10351035
int snmp_errno;
10361036
s->securityAuthKeyLen = USM_AUTH_KU_LEN;
10371037
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
1038-
(u_char *) ZSTR_VAL(pass), ZSTR_LEN(pass),
1038+
(uint8_t *) ZSTR_VAL(pass), ZSTR_LEN(pass),
10391039
s->securityAuthKey, &(s->securityAuthKeyLen)))) {
10401040
php_error_docref(NULL, E_WARNING, "Error generating a key for authentication pass phrase '%s': %s", ZSTR_VAL(pass), snmp_api_errstring(snmp_errno));
10411041
return false;
@@ -1051,7 +1051,7 @@ static bool netsnmp_session_gen_sec_key(struct snmp_session *s, zend_string *pas
10511051

10521052
s->securityPrivKeyLen = USM_PRIV_KU_LEN;
10531053
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
1054-
(u_char *)ZSTR_VAL(pass), ZSTR_LEN(pass),
1054+
(uint8_t *)ZSTR_VAL(pass), ZSTR_LEN(pass),
10551055
s->securityPrivKey, &(s->securityPrivKeyLen)))) {
10561056
php_error_docref(NULL, E_WARNING, "Error generating a key for privacy pass phrase '%s': %s", ZSTR_VAL(pass), snmp_api_errstring(snmp_errno));
10571057
return false;
@@ -1064,7 +1064,7 @@ static bool netsnmp_session_gen_sec_key(struct snmp_session *s, zend_string *pas
10641064
static bool netsnmp_session_set_contextEngineID(struct snmp_session *s, zend_string * contextEngineID)
10651065
{
10661066
size_t ebuf_len = 32, eout_len = 0;
1067-
u_char *ebuf = (u_char *) emalloc(ebuf_len);
1067+
uint8_t *ebuf = (uint8_t *) emalloc(ebuf_len);
10681068

10691069
if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, ZSTR_VAL(contextEngineID))) {
10701070
// TODO Promote to Error?

ext/standard/dns.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static zend_string *php_gethostbyname(char *name)
356356

357357
typedef union {
358358
HEADER qb1;
359-
u_char qb2[65536];
359+
uint8_t qb2[65536];
360360
} querybuf;
361361

362362
/* just a hack to free resources allocated by glibc in __res_nsend()
@@ -463,13 +463,13 @@ PHP_FUNCTION(dns_check_record)
463463
} while (0)
464464

465465
/* {{{ php_parserr */
466-
static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval *subarray)
466+
static uint8_t *php_parserr(uint8_t *cp, uint8_t *end, querybuf *answer, int type_to_fetch, int store, bool raw, zval *subarray)
467467
{
468468
u_short type, class, dlen;
469469
u_long ttl;
470470
long n, i;
471471
u_short s;
472-
u_char *tp, *p;
472+
uint8_t *tp, *p;
473473
char name[MAXHOSTNAMELEN] = {0};
474474
int have_v6_break = 0, in_v6_break = 0;
475475

@@ -648,12 +648,12 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
648648
add_assoc_long(subarray, "minimum-ttl", n);
649649
break;
650650
case DNS_T_AAAA:
651-
tp = (u_char*)name;
651+
tp = (uint8_t*)name;
652652
CHECKCP(8*2);
653653
for(i=0; i < 8; i++) {
654654
GETSHORT(s, cp);
655655
if (s != 0) {
656-
if (tp > (u_char *)name) {
656+
if (tp > (uint8_t *)name) {
657657
in_v6_break = 0;
658658
tp[0] = ':';
659659
tp++;
@@ -688,7 +688,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
688688
n = ((int)cp[0]) & 0xFF;
689689
cp++;
690690
add_assoc_long(subarray, "masklen", n);
691-
tp = (u_char*)name;
691+
tp = (uint8_t*)name;
692692
if (n > 15) {
693693
have_v6_break = 1;
694694
in_v6_break = 1;
@@ -698,7 +698,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
698698
if (n % 16 > 8) {
699699
/* Partial short */
700700
if (cp[0] != 0) {
701-
if (tp > (u_char *)name) {
701+
if (tp > (uint8_t *)name) {
702702
in_v6_break = 0;
703703
tp[0] = ':';
704704
tp++;
@@ -723,7 +723,7 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t
723723
CHECKCP(2);
724724
GETSHORT(s, cp);
725725
if (s != 0) {
726-
if (tp > (u_char *)name) {
726+
if (tp > (uint8_t *)name) {
727727
in_v6_break = 0;
728728
tp[0] = ':';
729729
tp++;
@@ -840,7 +840,7 @@ PHP_FUNCTION(dns_get_record)
840840
#endif
841841
HEADER *hp;
842842
querybuf answer = {0};
843-
u_char *cp = NULL, *end = NULL;
843+
uint8_t *cp = NULL, *end = NULL;
844844
int n, qd, an, ns = 0, ar = 0;
845845
int type, first_query = 1, store_results = 1;
846846
bool raw = 0;
@@ -1072,7 +1072,7 @@ PHP_FUNCTION(dns_get_mx)
10721072
querybuf answer = {0};
10731073
char buf[MAXHOSTNAMELEN] = {0};
10741074
HEADER *hp;
1075-
u_char *cp, *end;
1075+
uint8_t *cp, *end;
10761076
int i;
10771077
#if defined(HAVE_DNS_SEARCH)
10781078
struct sockaddr_storage from;
@@ -1116,7 +1116,7 @@ PHP_FUNCTION(dns_get_mx)
11161116
res_init();
11171117
#endif
11181118

1119-
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof answer);
1119+
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof(answer));
11201120
if (i < 0) {
11211121
php_dns_free_handle(handle);
11221122
RETURN_FALSE;

ext/standard/dns_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ PHP_FUNCTION(dns_check_record)
141141
/* }}} */
142142

143143
/* {{{ php_parserr */
144-
static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw, zval *subarray)
144+
static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, bool raw, zval *subarray)
145145
{
146146
int type;
147147
u_long ttl;
@@ -271,7 +271,7 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
271271

272272
for(i=0; i < 8; i++) {
273273
if (out[i] != 0) {
274-
if (tp > (u_char *)buf) {
274+
if (tp > (uint8_t *)buf) {
275275
in_v6_break = 0;
276276
tp[0] = ':';
277277
tp++;

win32/glob.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void qprintf(const char *, Char *);
159159

160160
PHPAPI int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
161161
{
162-
const u_char *patnext;
162+
const uint8_t *patnext;
163163
int c;
164164
Char *bufnext, *bufend, patbuf[MAXPATHLEN];
165165

@@ -170,7 +170,7 @@ PHPAPI int glob(const char *pattern, int flags, int (*errfunc)(const char *, int
170170
flags |= GLOB_NOESCAPE;
171171
#endif
172172

173-
patnext = (u_char *) pattern;
173+
patnext = (uint8_t *) pattern;
174174
if (!(flags & GLOB_APPEND)) {
175175
pglob->gl_pathc = 0;
176176
pglob->gl_pathv = NULL;
@@ -625,14 +625,14 @@ static int glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend
625625
else
626626
readdirfunc = readdir;
627627
while ((dp = (*readdirfunc)(dirp))) {
628-
register u_char *sc;
628+
register uint8_t *sc;
629629
register Char *dc;
630630

631631
/* Initial DOT must be matched literally. */
632632
if (dp->d_name[0] == DOT && *pattern != DOT)
633633
continue;
634634
dc = pathend;
635-
sc = (u_char *) dp->d_name;
635+
sc = (uint8_t *) dp->d_name;
636636
while (dc < pathend_last && (*dc++ = *sc++) != EOS)
637637
;
638638
if (dc >= pathend_last) {

0 commit comments

Comments
 (0)