Skip to content

Commit 7831901

Browse files
committed
Reviews
1 parent ba04f37 commit 7831901

6 files changed

+27
-18
lines changed

ext/snmp/snmp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static int php_snmp_parse_oid(
699699
objid_query->count++;
700700
} else if (oid_ht) { /* we got objid array */
701701
if (zend_hash_num_elements(oid_ht) == 0) {
702-
zend_value_error("Object ID cannot be an empty array");
702+
zend_value_error("Array of object IDs cannot be empty");
703703
return FALSE;
704704
}
705705
objid_query->vars = (snmpobjarg *)safe_emalloc(sizeof(snmpobjarg), zend_hash_num_elements(oid_ht), 0);
@@ -1838,7 +1838,7 @@ PHP_SNMP_LONG_PROPERTY_READER_FUNCTION(exceptions_enabled)
18381838
/* {{{ */
18391839
static int php_snmp_write_info(php_snmp_object *snmp_object, zval *newval)
18401840
{
1841-
zend_throw_error(NULL, "info property is read-only");
1841+
zend_throw_error(NULL, "SNMP::$info property is read-only");
18421842
return FAILURE;
18431843
}
18441844
/* }}} */
@@ -1856,7 +1856,7 @@ static int php_snmp_write_max_oids(php_snmp_object *snmp_object, zval *newval)
18561856
lval = zval_get_long(newval);
18571857

18581858
if (lval <= 0) {
1859-
zend_value_error("max_oids must be greater than 0 or NULL");
1859+
zend_value_error("max_oids must be greater than 0 or null");
18601860
return FAILURE;
18611861
}
18621862
snmp_object->max_oids = lval;
@@ -1873,7 +1873,7 @@ static int php_snmp_write_valueretrieval(php_snmp_object *snmp_object, zval *new
18731873
if (lval >= 0 && lval <= (SNMP_VALUE_LIBRARY|SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT)) {
18741874
snmp_object->valueretrieval = lval;
18751875
} else {
1876-
zend_value_error("SNMP retrieval method must be one of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, or SNMP_VALUE_OBJECT");
1876+
zend_value_error("SNMP retrieval method must be a bitmask of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, and SNMP_VALUE_OBJECT");
18771877
return FAILURE;
18781878
}
18791879

ext/snmp/tests/snmp-object-error.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ int(32)
9898
string(46) "Invalid object identifier: .1.3.6.1.2.1.1.1..0"
9999
bool(true)
100100
Open normal session
101-
SNMP retrieval method must be one of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, or SNMP_VALUE_OBJECT
101+
SNMP retrieval method must be a bitmask of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, and SNMP_VALUE_OBJECT
102102
Closing session
103103
bool(true)
104104
Invalid or uninitialized SNMP object
105105
NULL
106-
max_oids must be greater than 0 or NULL
107-
max_oids must be greater than 0 or NULL
106+
max_oids must be greater than 0 or null
107+
max_oids must be greater than 0 or null
108108
NULL

ext/snmp/tests/snmp-object-properties.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,5 @@ NULL
192192
bool(false)
193193
SNMP retrieval method must be one of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, or SNMP_VALUE_OBJECT
194194
SNMP output print format must be an SNMP_OID_OUTPUT_* constant
195-
info property is read-only
195+
SNMP::$info property is read-only
196196
NULL

ext/snmp/tests/snmp2_get.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.
5151
--EXPECTF--
5252
Checking error handling
5353
Empty OID array
54-
Object ID cannot be an empty array
54+
Array of object IDs cannot be empty
5555
Checking working
5656
Single OID
5757
string(%d) "%s"

ext/snmp/tests/snmp_get_valueretrieval.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump(snmp_get_valueretrieval() === (SNMP_VALUE_LIBRARY|SNMP_VALUE_OBJECT));
3333
?>
3434
--EXPECTF--
3535
Checking error handling
36-
snmp_set_valueretrieval(): Argument #1 ($method) must be one of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, or SNMP_VALUE_OBJECT
36+
snmp_set_valueretrieval(): Argument #1 ($method) must be a bitmask of SNMP_VALUE_LIBRARY, SNMP_VALUE_PLAIN, and SNMP_VALUE_OBJECT
3737
Checking working
3838
int(%d)
3939
bool(true)

ext/snmp/tests/snmpset.phpt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,41 +83,42 @@ echo "Single OID, single type in array, single value\n";
8383
try {
8484
$z = snmpset($hostname, $communityWrite, $oid1, array('s'), $newvalue1, $timeout, $retries);
8585
var_dump($z);
86-
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
87-
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
8886
} catch (\TypeError $e) {
8987
echo $e->getMessage() . \PHP_EOL;
9088
}
89+
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
90+
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
9191

9292
echo "Single OID, single type, single value in array\n";
9393
try {
9494
$z = snmpset($hostname, $communityWrite, $oid1, 's', array($newvalue1), $timeout, $retries);
9595
var_dump($z);
96-
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
97-
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
9896
} catch (\TypeError $e) {
9997
echo $e->getMessage() . \PHP_EOL;
10098
}
99+
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
100+
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
101101

102102
echo "Multiple OID, 1st wrong type\n";
103103
try {
104104
$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('sw','s'), array($newvalue1, $newvalue2), $timeout, $retries);
105105
var_dump($z);
106-
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
107-
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
108106
} catch (\ValueError $e) {
109107
echo $e->getMessage() . \PHP_EOL;
110108
}
109+
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
110+
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
111111

112112
echo "Multiple OID, 2nd wrong type\n";
113113
try {
114114
$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','sb'), array($newvalue1, $newvalue2), $timeout, $retries);
115115
var_dump($z);
116-
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
117-
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
118116
} catch (\ValueError $e) {
119117
echo $e->getMessage() . \PHP_EOL;
120118
}
119+
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
120+
var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
121+
121122
echo "Multiple OID, single type in array, multiple value\n";
122123
$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s'), array($newvalue1, $newvalue2), $timeout, $retries);
123124
var_dump($z);
@@ -197,12 +198,20 @@ bool(true)
197198
More error handing
198199
Single OID, single type in array, single value
199200
Type must be of type string when object ID is a string
201+
bool(true)
202+
bool(true)
200203
Single OID, single type, single value in array
201204
Value must be of type string when object ID is a string
205+
bool(true)
206+
bool(true)
202207
Multiple OID, 1st wrong type
203208
Type must be a single character
209+
bool(true)
210+
bool(true)
204211
Multiple OID, 2nd wrong type
205212
Type must be a single character
213+
bool(true)
214+
bool(true)
206215
Multiple OID, single type in array, multiple value
207216

208217
Warning: snmpset(): '%s': no type set in %s on line %d

0 commit comments

Comments
 (0)