Skip to content

Refactor SNMP extension a bit #6846

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Apr 8, 2021

Use RETURN_* macros instead of RETVAL_* + return;
Use proper boolean types
Use zend_string instead of char* to prevent unnecessary strlen calculation

Use RETURN_* macros instead of RETVAL_* + return;
Use proper boolean types
Use zend_string instead of char* to prevent unnecessary strlen calculation
@@ -574,7 +569,7 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,

/* OID increase check */
if (st & SNMP_CMD_WALK) {
if (objid_query->oid_increasing_check == TRUE && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {
if (objid_query->oid_increasing_check == true && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (objid_query->oid_increasing_check == true && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {
if (objid_query->oid_increasing_check && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {

@@ -668,20 +660,20 @@ static int php_snmp_parse_oid(
zval *tmp_oid, *tmp_type, *tmp_value;

objid_query->count = 0;
objid_query->array_output = ((st & SNMP_CMD_WALK) ? TRUE : FALSE);
objid_query->array_output = ((st & SNMP_CMD_WALK) ? true : false);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
objid_query->array_output = ((st & SNMP_CMD_WALK) ? true : false);
objid_query->array_output = (st & SNMP_CMD_WALK) != 0;

}
objid_query->vars = (snmpobjarg *)safe_emalloc(sizeof(snmpobjarg), zend_hash_num_elements(oid_ht), 0);
objid_query->array_output = ( (st & SNMP_CMD_SET) ? FALSE : TRUE );
objid_query->array_output = ( (st & SNMP_CMD_SET) ? false : true );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
objid_query->array_output = ( (st & SNMP_CMD_SET) ? false : true );
objid_query->array_output = (st & SNMP_CMD_SET) != 0;

@Girgias Girgias closed this in 6333195 Apr 9, 2021
@Girgias Girgias deleted the refactor-snmp branch April 9, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants