[PHP-CVS] [php-src] master: snmp: use book type for boolean options and rename variables

[email protected] (Steve Wilton via Gina Peter Banyard)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: Steve Wilton (eskyuu)
Committer: Gina Peter Banyard (Girgias)
Date: 2026-08-22T14:28:38+01:00

Commit: https://github.com/php/php-src/commit/7268b84ec1aef301f991a4d3c2f572e2ec051413
Raw diff: https://github.com/php/php-src/commit/7268b84ec1aef301f991a4d3c2f572e2ec051413.diff

snmp: use book type for boolean options and rename variables

Changed paths:
  M  ext/snmp/php_snmp.h
  M  ext/snmp/snmp.c


Diff:

diff --git a/ext/snmp/php_snmp.h b/ext/snmp/php_snmp.h
index d889eb37ab95..a9a7926504f5 100644
--- a/ext/snmp/php_snmp.h
+++ b/ext/snmp/php_snmp.h
@@ -46,11 +46,11 @@ typedef struct _php_snmp_object {
 	struct snmp_session *session;
 	int max_oids;
 	int valueretrieval;
-	int quick_print;
-	int enum_print;
+	bool quick_print;
+	bool enum_print;
 	int oid_output_format;
 	int snmp_errno;
-	int oid_increasing_check;
+	bool oid_increasing_check;
 	int exceptions_enabled;
 	char snmp_errstr[256];
 	zend_object zo;
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index e921adb98352..54d2b1f5ac79 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -1502,13 +1502,13 @@ PHP_FUNCTION(snmp_get_quick_print)
 /* {{{ Return all objects including their respective object id within the specified one */
 PHP_FUNCTION(snmp_set_quick_print)
 {
-	bool a1;
+	bool quick_print;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &a1) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &quick_print) == FAILURE) {
 		RETURN_THROWS();
 	}
 
-	netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, (int)a1);
+	netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, (int)quick_print);
 	RETURN_TRUE;
 }
 /* }}} */
@@ -1516,13 +1516,13 @@ PHP_FUNCTION(snmp_set_quick_print)
 /* {{{ Return all values that are enums with their enum value instead of the raw integer */
 PHP_FUNCTION(snmp_set_enum_print)
 {
-	bool a1;
+	bool enum_print;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &a1) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enum_print) == FAILURE) {
 		RETURN_THROWS();
 	}
 
-	netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);
+	netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int)enum_print);
 	RETURN_TRUE;
 }
 /* }}} */
@@ -1530,20 +1530,20 @@ PHP_FUNCTION(snmp_set_enum_print)
 /* {{{ Set the OID output format. */
 PHP_FUNCTION(snmp_set_oid_output_format)
 {
-	zend_long a1;
+	zend_long format;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &a1) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE) {
 		RETURN_THROWS();
 	}
 
-	switch (a1) {
+	switch (format) {
 		case NETSNMP_OID_OUTPUT_SUFFIX:
 		case NETSNMP_OID_OUTPUT_MODULE:
 		case NETSNMP_OID_OUTPUT_FULL:
 		case NETSNMP_OID_OUTPUT_NUMERIC:
 		case NETSNMP_OID_OUTPUT_UCD:
 		case NETSNMP_OID_OUTPUT_NONE:
-			netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, a1);
+			netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, format);
 			RETURN_TRUE;
 		default:
 			zend_argument_value_error(1, "must be an SNMP_OID_OUTPUT_* constant");
@@ -1696,14 +1696,14 @@ PHP_METHOD(SNMP, __construct)
 {
 	php_snmp_object *snmp_object;
 	zval *object = ZEND_THIS;
-	zend_string *a1, *a2;
+	zend_string *hostname, *community;
 	zend_long timeout = SNMP_DEFAULT_TIMEOUT;
 	zend_long retries = SNMP_DEFAULT_RETRIES;
 	zend_long version = SNMP_DEFAULT_VERSION;
 
 	snmp_object = Z_SNMP_P(object);
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lPP|ll", &version, &a1, &a2, &timeout, &retries) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lPP|ll", &version, &hostname, &community, &timeout, &retries) == FAILURE) {
 		RETURN_THROWS();
 	}
 
@@ -1722,7 +1722,7 @@ PHP_METHOD(SNMP, __construct)
 		snmp_session_free(&(snmp_object->session));
 	}
 
-	if (!snmp_session_init(&(snmp_object->session), version, a1, a2, timeout, retries, 2, 4)) {
+	if (!snmp_session_init(&(snmp_object->session), version, hostname, community, timeout, retries, 2, 4)) {
 		return;
 	}
 	snmp_object->max_oids = 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.