Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings #38

Merged
merged 3 commits into from
Jun 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions mustache_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ static zend_object * MustacheAST_obj_create(zend_class_entry * ce TSRMLS_DC)
zend_object_std_init(&intern->std, ce TSRMLS_CC);
intern->std.handlers = &MustacheAST_obj_handlers;
intern->node = NULL;
return &intern->std;
} catch(...) {
mustache_exception_handler(TSRMLS_C);
}
return &intern->std;

return NULL;
}
#endif
/* }}} */
Expand Down Expand Up @@ -271,7 +272,6 @@ PHP_METHOD(MustacheAST, __construct)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheAST * payload = php_mustache_ast_object_fetch_object(_this_zval TSRMLS_CC);

// Check payload
Expand Down Expand Up @@ -301,7 +301,6 @@ PHP_METHOD(MustacheAST, __sleep)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheAST * payload = php_mustache_ast_object_fetch_object(_this_zval TSRMLS_CC);

array_init(return_value);
Expand Down Expand Up @@ -339,7 +338,6 @@ PHP_METHOD(MustacheAST, toArray)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheAST * payload = php_mustache_ast_object_fetch_object(_this_zval TSRMLS_CC);

// Check payload
Expand Down Expand Up @@ -369,7 +367,6 @@ PHP_METHOD(MustacheAST, __toString)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheAST * payload = php_mustache_ast_object_fetch_object(_this_zval TSRMLS_CC);

// Check payload
Expand Down Expand Up @@ -397,7 +394,6 @@ PHP_METHOD(MustacheAST, __toString)
static inline void php_mustache_ast_wakeup(zval * _this_zval, zval * return_value TSRMLS_DC)
{
zval rv;
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheAST * payload = php_mustache_ast_object_fetch_object(_this_zval TSRMLS_CC);
zval * value = _zend_read_property(Z_OBJCE_P(_this_zval), _this_zval, "binaryString", sizeof("binaryString")-1, 1, &rv);

Expand Down
1 change: 0 additions & 1 deletion mustache_class_method_lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ClassMethodLambda::~ClassMethodLambda()
int ClassMethodLambda::getUserFunctionParamCount()
{
zend_class_entry * ce = Z_OBJCE_P(object);
HashTable * function_table = NULL;
zval * zv = NULL;
zend_function * function_entry = NULL;

Expand Down
11 changes: 7 additions & 4 deletions mustache_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ static zend_object * MustacheData_obj_create(zend_class_entry * ce TSRMLS_DC)
intern = (struct php_obj_MustacheData *) ecalloc(1, sizeof(struct php_obj_MustacheData) + zend_object_properties_size(ce));
zend_object_std_init(&intern->std, ce TSRMLS_CC);
intern->std.handlers = &MustacheData_obj_handlers;
return &intern->std;
} catch(...) {
mustache_exception_handler(TSRMLS_C);
}
return &intern->std;

return NULL;
}
#endif
/* }}} */
Expand Down Expand Up @@ -252,7 +253,6 @@ static zend_always_inline void mustache_data_from_array_zval(mustache::Data * no

int length = 0;
mustache::Data * child = NULL;
zend_class_entry * ce = NULL;

node->type = mustache::Data::TypeNone;

Expand All @@ -266,6 +266,7 @@ static zend_always_inline void mustache_data_from_array_zval(mustache::Data * no

data_count = zend_hash_num_elements(data_hash);
ZEND_HASH_FOREACH_KEY_VAL_IND(data_hash, key_nindex, key, data_entry) {
(void)key_nindex; /* avoid [-Wunused-but-set-variable] */
if( !key ) {
if( node->type == mustache::Data::TypeNone ) {
node->init(mustache::Data::TypeArray, data_count);
Expand Down Expand Up @@ -388,7 +389,6 @@ static zend_always_inline void mustache_data_from_object_properties_zval(mustach
static zend_always_inline void mustache_data_from_object_properties_zval(mustache::Data * node, zval * current TSRMLS_DC)
{
HashTable * data_hash = NULL;
long data_count = 0;
ulong key_nindex = 0;
zend_string * key;
std::string ckey;
Expand All @@ -415,6 +415,7 @@ static zend_always_inline void mustache_data_from_object_properties_zval(mustach
}

ZEND_HASH_FOREACH_KEY_VAL_IND(data_hash, key_nindex, key, data_entry) {
(void)key_nindex; /* avoid [-Wunused-but-set-variable] */
if( key && ZSTR_LEN(key) && ZSTR_VAL(key)[0] ) { // skip private/protected
prop_name = ZSTR_VAL(key);

Expand Down Expand Up @@ -517,6 +518,8 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache

ZEND_HASH_FOREACH_KEY_VAL_IND(data_hash, key_nindex, key, data_entry) {
function_entry = (zend_function *) Z_PTR_P(data_entry);
(void)key; /* avoid [-Wunused-but-set-variable] */
(void)key_nindex;
if( is_valid_function(function_entry) ) {
node->type = mustache::Data::TypeMap;

Expand Down
5 changes: 2 additions & 3 deletions mustache_lambda_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ static zend_object * MustacheLambdaHelper_obj_create(zend_class_entry * ce TSRML
intern = (struct php_obj_MustacheLambdaHelper *) ecalloc(1, sizeof(struct php_obj_MustacheLambdaHelper) + zend_object_properties_size(ce));
zend_object_std_init(&intern->std, ce TSRMLS_CC);
intern->std.handlers = &MustacheLambdaHelper_obj_handlers;
return &intern->std;
} catch(...) {
mustache_exception_handler(TSRMLS_C);
}

return &intern->std;
return NULL;
}
#endif
/* }}} */
Expand Down Expand Up @@ -149,7 +149,6 @@ PHP_METHOD(MustacheLambdaHelper, render)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_MustacheLambdaHelper * payload = php_mustache_lambda_helper_object_fetch_object(_this_zval TSRMLS_CC);

std::string templateStr(template_str/*, (size_t) Z_STRLEN_P(template_str)*/);
Expand Down
19 changes: 4 additions & 15 deletions mustache_mustache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,12 @@ static zend_object * Mustache_obj_create(zend_class_entry * ce TSRMLS_DC)
intern->std.handlers = &Mustache_obj_handlers;

intern->mustache = mustache_new_Mustache(TSRMLS_C);
return &intern->std;
} catch(...) {
mustache_exception_handler(TSRMLS_C);
}

return &intern->std;
return NULL;
}
#endif
/* }}} */
Expand Down Expand Up @@ -321,6 +322,7 @@ bool mustache_parse_partials_param(zval * array, mustache::Mustache * mustache,
zend_string * key = NULL;

ZEND_HASH_FOREACH_KEY_VAL(data_hash, key_nindex, key, data_entry) {
(void)key_nindex;
if( !key ) {
php_error(E_WARNING, "Partial array contains a non-string key");
} else {
Expand All @@ -329,6 +331,7 @@ bool mustache_parse_partials_param(zval * array, mustache::Mustache * mustache,
} ZEND_HASH_FOREACH_END();
} while(0);
#endif
return true;
}
/* }}} */

Expand Down Expand Up @@ -405,8 +408,6 @@ PHP_METHOD(Mustache, __construct)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

} catch(...) {
mustache_exception_handler(TSRMLS_C);
Expand All @@ -427,7 +428,6 @@ PHP_METHOD(Mustache, getEscapeByDefault)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand Down Expand Up @@ -456,7 +456,6 @@ PHP_METHOD(Mustache, getStartSequence)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand All @@ -482,7 +481,6 @@ PHP_METHOD(Mustache, getStopSequence)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand Down Expand Up @@ -511,7 +509,6 @@ PHP_METHOD(Mustache, setEscapeByDefault)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand Down Expand Up @@ -541,7 +538,6 @@ PHP_METHOD(Mustache, setStartSequence)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand Down Expand Up @@ -571,7 +567,6 @@ PHP_METHOD(Mustache, setStopSequence)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Main
Expand Down Expand Up @@ -601,7 +596,6 @@ PHP_METHOD(Mustache, compile)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare template tree
Expand Down Expand Up @@ -649,7 +643,6 @@ PHP_METHOD(Mustache, execute)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare code
Expand Down Expand Up @@ -753,7 +746,6 @@ PHP_METHOD(Mustache, render)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare template tree
Expand Down Expand Up @@ -811,7 +803,6 @@ PHP_METHOD(Mustache, tokenize)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Assign template to string
Expand Down Expand Up @@ -846,8 +837,6 @@ PHP_METHOD(Mustache, debugDataStructure)

// Class parameters
_this_zval = getThis();
zend_class_entry * _this_ce = Z_OBJCE_P(_this_zval);
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare template data
mustache::Data templateData;
Expand Down
2 changes: 1 addition & 1 deletion php_mustache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ zend_module_entry mustache_module_entry = {
(char *) PHP_MUSTACHE_NAME, /* Name */
NULL, /* Functions */
PHP_MINIT(mustache), /* MINIT */
NULL, /* MSHUTDOWN */
PHP_MSHUTDOWN(mustache), /* MSHUTDOWN */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that was bad.

NULL, /* RINIT */
NULL, /* RSHUTDOWN */
PHP_MINFO(mustache), /* MINFO */
Expand Down