Skip to content

Commit 9ad97cd

Browse files
committed
Reduce (some) compile noise of 'unused variable' and 'may be used uninitialized' warnings.
1 parent 9d62807 commit 9ad97cd

File tree

23 files changed

+31
-33
lines changed

23 files changed

+31
-33
lines changed

ext/date/php_date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
997997
static char *date_format(char *format, int format_len, timelib_time *t, int localtime)
998998
{
999999
smart_str string = {0};
1000-
int i, length;
1000+
int i, length = 0;
10011001
char buffer[97];
10021002
timelib_time_offset *offset = NULL;
10031003
timelib_sll isoweek, isoyear;
@@ -2409,8 +2409,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
24092409
timelib_time *now;
24102410
timelib_tzinfo *tzi = NULL;
24112411
timelib_error_container *err = NULL;
2412-
int type = TIMELIB_ZONETYPE_ID, new_dst;
2413-
char *new_abbr;
2412+
int type = TIMELIB_ZONETYPE_ID, new_dst = 0;
2413+
char *new_abbr = NULL;
24142414
timelib_sll new_offset;
24152415

24162416
if (dateobj->time) {

ext/dba/dba.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ PHP_MINFO_FUNCTION(dba)
538538
*/
539539
static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
540540
{
541-
char *v;
542541
int val_len;
543542
zval *id;
544543
dba_info *info = NULL;

ext/dba/libinifile/inifile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML
460460
*/
461461
static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append TSRMLS_DC)
462462
{
463-
size_t pos_grp_start, pos_grp_next;
463+
size_t pos_grp_start = 0, pos_grp_next;
464464
inifile *ini_tmp = NULL;
465465
php_stream *fp_tmp = NULL;
466466
int ret;

ext/dom/xpath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const zend_function_entry php_dom_xpath_class_functions[] = {
7474

7575
static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */
7676
{
77-
zval **args;
77+
zval **args = NULL;
7878
zval *retval;
7979
int result, i, ret;
8080
int error = 0;

ext/gmp/gmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ ZEND_FUNCTION(gmp_powm)
10691069
zval **base_arg, **exp_arg, **mod_arg;
10701070
mpz_t *gmpnum_base, *gmpnum_exp, *gmpnum_mod, *gmpnum_result;
10711071
int use_ui = 0;
1072-
int temp_base, temp_exp, temp_mod;
1072+
int temp_base = 0, temp_exp = 0, temp_mod;
10731073

10741074
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ", &base_arg, &exp_arg, &mod_arg) == FAILURE){
10751075
return;

ext/intl/grapheme/grapheme_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void grapheme_substr_ascii(char *str, int str_len, int f, int l, int argc, char
130130
/* {{{ grapheme_strpos_utf16 - strrpos using utf16*/
131131
int grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last TSRMLS_DC)
132132
{
133-
UChar *uhaystack = NULL, *puhaystack, *uneedle = NULL;
133+
UChar *uhaystack = NULL, *uneedle = NULL;
134134
int32_t uhaystack_len = 0, uneedle_len = 0, char_pos, ret_pos, offset_pos = 0;
135135
unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE];
136136
UBreakIterator* bi = NULL;

ext/intl/resourcebundle/resourcebundle_class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ PHP_FUNCTION( resourcebundle_create )
162162
/* {{{ resourcebundle_array_fetch */
163163
static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_value, int fallback TSRMLS_DC)
164164
{
165-
int32_t meindex;
166-
char * mekey;
165+
int32_t meindex = 0;
166+
char * mekey = NULL;
167167
long mekeylen;
168168
zend_bool is_numeric = 0;
169169
char *pbuf;

ext/openssl/openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
578578

579579
for (i = 0; i < X509_NAME_entry_count(name); i++) {
580580
unsigned char *to_add;
581-
int to_add_len;
581+
int to_add_len = 0;
582582

583583

584584
ne = X509_NAME_get_entry(name, i);

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
472472

473473
do {
474474
struct timeval cur_time,
475-
elapsed_time;
475+
elapsed_time = {0};
476476

477477
if (sslsock->is_client) {
478478
n = SSL_connect(sslsock->ssl_handle);

ext/session/session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
281281
PHP_MD5_CTX md5_context;
282282
PHP_SHA1_CTX sha1_context;
283283
#if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
284-
void *hash_context;
284+
void *hash_context = NULL;
285285
#endif
286286
unsigned char *digest;
287287
int digest_len;

ext/simplexml/simplexml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
10701070
int namelen;
10711071
int test;
10721072
char use_iter;
1073-
zval *iter_data;
1073+
zval *iter_data = NULL;
10741074

10751075
use_iter = 0;
10761076

ext/snmp/snmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS
514514
static void php_snmp_error(zval *object, const char *docref TSRMLS_DC, int type, const char *format, ...)
515515
{
516516
va_list args;
517-
php_snmp_object *snmp_object;
517+
php_snmp_object *snmp_object = NULL;
518518

519519
if (object) {
520520
snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC);

ext/spl/spl_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
166166
/* {{{ spl_array_object_new_ex */
167167
static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, spl_array_object **obj, zval *orig, int clone_orig TSRMLS_DC)
168168
{
169-
zend_object_value retval;
169+
zend_object_value retval = {0};
170170
spl_array_object *intern;
171171
zval *tmp;
172172
zend_class_entry * parent = class_type;

ext/spl/spl_dllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
368368

369369
static zend_object_value spl_dllist_object_new_ex(zend_class_entry *class_type, spl_dllist_object **obj, zval *orig, int clone_orig TSRMLS_DC) /* {{{ */
370370
{
371-
zend_object_value retval;
371+
zend_object_value retval = {0};
372372
spl_dllist_object *intern;
373373
zend_class_entry *parent = class_type;
374374
int inherited = 0;

ext/standard/array.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,8 +2996,8 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
29962996
char *param_spec;
29972997
zend_fcall_info fci1, fci2;
29982998
zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
2999-
zend_fcall_info *fci_key, *fci_data;
3000-
zend_fcall_info_cache *fci_key_cache, *fci_data_cache;
2999+
zend_fcall_info *fci_key = NULL, *fci_data;
3000+
zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache;
30013001
PHP_ARRAY_CMP_FUNC_VARS;
30023002

30033003
int (*intersect_key_compare_func)(const void *, const void * TSRMLS_DC);
@@ -3414,8 +3414,8 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
34143414
char *param_spec;
34153415
zend_fcall_info fci1, fci2;
34163416
zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
3417-
zend_fcall_info *fci_key, *fci_data;
3418-
zend_fcall_info_cache *fci_key_cache, *fci_data_cache;
3417+
zend_fcall_info *fci_key = NULL, *fci_data;
3418+
zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache;
34193419
PHP_ARRAY_CMP_FUNC_VARS;
34203420

34213421
int (*diff_key_compare_func)(const void *, const void * TSRMLS_DC);
@@ -4019,7 +4019,6 @@ PHP_FUNCTION(array_sum)
40194019
**entry,
40204020
entry_n;
40214021
HashPosition pos;
4022-
double dval;
40234022

40244023
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) {
40254024
return;

ext/standard/html.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,8 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
12211221
const enc_to_uni *to_uni_table = NULL;
12221222
const entity_ht *inv_map = NULL; /* used for !double_encode */
12231223
/* only used if flags includes ENT_HTML_IGNORE_ERRORS or ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS */
1224-
const unsigned char *replacement;
1225-
size_t replacement_len;
1224+
const unsigned char *replacement = NULL;
1225+
size_t replacement_len = 0;
12261226

12271227
if (all) { /* replace with all named entities */
12281228
if (CHARSET_PARTIAL_SUPPORT(charset)) {
@@ -1596,7 +1596,7 @@ PHP_FUNCTION(get_html_translation_table)
15961596
flags = ENT_COMPAT;
15971597
int doctype;
15981598
entity_table_opt entity_table;
1599-
const enc_to_uni *to_uni_table;
1599+
const enc_to_uni *to_uni_table = NULL;
16001600
char *charset_hint = NULL;
16011601
int charset_hint_len;
16021602
enum entity_charset charset;

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,7 @@ static void php_similar_str(const char *txt1, int len1, const char *txt2, int le
32533253
static int php_similar_char(const char *txt1, int len1, const char *txt2, int len2)
32543254
{
32553255
int sum;
3256-
int pos1, pos2, max;
3256+
int pos1 = 0, pos2 = 0, max;
32573257

32583258
php_similar_str(txt1, len1, txt2, len2, &pos1, &pos2, &max);
32593259
if ((sum = max)) {
@@ -4613,7 +4613,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
46134613
char *tbuf, *buf, *p, *tp, *rp, c, lc;
46144614
int br, i=0, depth=0, in_q = 0;
46154615
int state = 0, pos;
4616-
char *allow_free;
4616+
char *allow_free = NULL;
46174617

46184618
if (stateptr)
46194619
state = *stateptr;

ext/standard/url_scanner_ex.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
463463

464464
PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC)
465465
{
466-
char *encoded;
466+
char *encoded = NULL;
467467
int encoded_len;
468468
smart_str val;
469469

ext/xsl/xsltprocessor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
476476

477477
static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp TSRMLS_DC) /* {{{ */
478478
{
479-
xmlDocPtr newdocp;
479+
xmlDocPtr newdocp = NULL;
480480
xmlDocPtr doc = NULL;
481481
xmlNodePtr node = NULL;
482482
xsltTransformContextPtr ctxt;

ext/zip/php_zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
16541654
char *path = NULL;
16551655
char *remove_path = NULL;
16561656
char *add_path = NULL;
1657-
int pattern_len, add_path_len, remove_path_len, path_len = 0;
1657+
int pattern_len, add_path_len = 0, remove_path_len = 0, path_len = 0;
16581658
long remove_all_path = 0;
16591659
long flags = 0;
16601660
zval *options = NULL;

main/php_variables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zva
5656
PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array TSRMLS_DC)
5757
{
5858
char *p = NULL;
59-
char *ip; /* index pointer */
59+
char *ip = NULL; /* index pointer */
6060
char *index;
6161
char *var, *var_orig;
6262
int var_len, index_len;

main/rfc1867.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
398398
static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
399399
{
400400
char *line;
401-
mime_header_entry prev_entry, entry;
401+
mime_header_entry prev_entry = {0}, entry;
402402
int prev_len, cur_len;
403403

404404
/* didn't find boundary, abort */

sapi/cli/php_cli_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
13251325
static const char *index_files[] = { "index.php", "index.html", NULL };
13261326
char *buf = safe_pemalloc(1, request->vpath_len, 1 + document_root_len + 1 + sizeof("index.html"), 1);
13271327
char *p = buf, *prev_path = NULL, *q, *vpath;
1328-
size_t prev_path_len;
1328+
size_t prev_path_len = 0;
13291329
int is_static_file = 0;
13301330

13311331
if (!buf) {

0 commit comments

Comments
 (0)