Skip to content

Commit 4d11d90

Browse files
committed
Track down a few more functions that don't check for 0 args and use
faster mechanism
1 parent 5b2227e commit 4d11d90

File tree

17 files changed

+79
-46
lines changed

17 files changed

+79
-46
lines changed

ext/curl/curl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,9 @@ static void curl_free_slist(void **slist)
504504
Return the CURL version string. */
505505
PHP_FUNCTION(curl_version)
506506
{
507-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
508-
return;
507+
if (ZEND_NUM_ARGS() != 0) {
508+
WRONG_PARAM_COUNT;
509+
}
509510

510511
RETURN_STRING(curl_version(), 1);
511512
}

ext/db/db.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@ PHP_MINFO_FUNCTION(db)
252252
Describes the dbm-compatible library being used */
253253
PHP_FUNCTION(dblist)
254254
{
255-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
256-
return;
255+
if (ZEND_NUM_ARGS() != 0) {
256+
WRONG_PARAM_COUNT;
257+
}
257258

258259
char *str = php_get_info_db();
259260
RETURN_STRING(str, 1);

ext/domxml/php_domxml.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,8 +2432,9 @@ PHP_FUNCTION(xmltree)
24322432
Initializing XPath environment */
24332433
PHP_FUNCTION(xpath_init)
24342434
{
2435-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
2436-
return;
2435+
if (ZEND_NUM_ARGS() != 0) {
2436+
WRONG_PARAM_COUNT;
2437+
}
24372438

24382439
xmlXPathInit();
24392440
RETURN_TRUE;

ext/fdf/fdf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ PHP_FUNCTION(fdf_create)
209209
FDFDoc fdf;
210210
FDFErc err;
211211

212-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
213-
return;
212+
if (ZEND_NUM_ARGS() != 0) {
213+
WRONG_PARAM_COUNT;
214+
}
214215

215216
err = FDFCreate(&fdf);
216217

ext/gd/gd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,9 @@ PHP_FUNCTION(imagetypes)
931931
#ifdef HAVE_GD_XPM
932932
ret |= 16;
933933
#endif
934-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
935-
return;
934+
if (ZEND_NUM_ARGS() != 0) {
935+
WRONG_PARAM_COUNT;
936+
}
936937

937938
RETURN_LONG(ret);
938939
}

ext/hyperwave/hw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,9 @@ PHP_FUNCTION(hw_errormsg)
13311331
Returns object id of root collection */
13321332
PHP_FUNCTION(hw_root)
13331333
{
1334-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
1335-
return;
1334+
if (ZEND_NUM_ARGS() != 0) {
1335+
WRONG_PARAM_COUNT;
1336+
}
13361337

13371338
return_value->value.lval = 0;
13381339
return_value->type = IS_LONG;

ext/interbase/interbase.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ typedef struct {
236236
Return error message */
237237
PHP_FUNCTION(ibase_errmsg)
238238
{
239-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
240-
return;
239+
if (ZEND_NUM_ARGS() != 0) {
240+
WRONG_PARAM_COUNT;
241+
}
241242

242243
if (IBG(errmsg[0])) {
243244
RETURN_STRING(IBG(errmsg), 1);

ext/mhash/mhash.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ static PHP_MINIT_FUNCTION(mhash)
8383
Gets the number of available hashes */
8484
PHP_FUNCTION(mhash_count)
8585
{
86-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
87-
return;
86+
if (ZEND_NUM_ARGS() != 0) {
87+
WRONG_PARAM_COUNT;
88+
}
8889

8990
RETURN_LONG(mhash_count());
9091
}

ext/odbc/php_odbc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ PHP_FUNCTION(odbc_close_all)
711711
int i;
712712
int nument;
713713

714-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
715-
return;
714+
if (ZEND_NUM_ARGS() != 0) {
715+
WRONG_PARAM_COUNT;
716+
}
716717

717718
nument = zend_hash_next_free_element(&EG(regular_list));
718719

ext/sablot/sablot.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ PHP_FUNCTION(xslt_output_endtransform)
292292
*buffer = NULL;
293293
int ret = 0;
294294

295-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
296-
return;
295+
if (ZEND_NUM_ARGS() != 0) {
296+
WRONG_PARAM_COUNT;
297+
}
297298

298299
/**
299300
* Make sure that we don't have more than one output buffer going on
@@ -551,7 +552,6 @@ PHP_FUNCTION(xslt_process)
551552
}
552553
/* }}} */
553554

554-
555555
/* {{{ proto resource xslt_create(void)
556556
Create a new XSL processor and return a resource identifier. */
557557
PHP_FUNCTION(xslt_create)
@@ -560,8 +560,9 @@ PHP_FUNCTION(xslt_create)
560560
SablotHandle p;
561561
int ret;
562562

563-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
564-
return;
563+
if (ZEND_NUM_ARGS() != 0) {
564+
WRONG_PARAM_COUNT;
565+
}
565566

566567
ret = SablotCreateProcessor(&p);
567568

ext/session/session.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,8 +1229,9 @@ PHP_FUNCTION(session_encode)
12291229
int len;
12301230
char *enc;
12311231

1232-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
1233-
return;
1232+
if (ZEND_NUM_ARGS() != 0) {
1233+
WRONG_PARAM_COUNT;
1234+
}
12341235

12351236
enc = php_session_encode(&len TSRMLS_CC);
12361237
RETVAL_STRINGL(enc, len, 0);
@@ -1266,8 +1267,9 @@ PHP_FUNCTION(session_start)
12661267
Destroy the current session and all data associated with it */
12671268
PHP_FUNCTION(session_destroy)
12681269
{
1269-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
1270-
return;
1270+
if (ZEND_NUM_ARGS() != 0) {
1271+
WRONG_PARAM_COUNT;
1272+
}
12711273

12721274
if (php_session_destroy(TSRMLS_C) == SUCCESS) {
12731275
RETURN_TRUE;

ext/snmp/snmp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,9 @@ PHP_FUNCTION(snmprealwalk)
402402
Return the current status of quick_print */
403403
PHP_FUNCTION(snmp_get_quick_print)
404404
{
405-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
406-
return;
405+
if (ZEND_NUM_ARGS() != 0) {
406+
WRONG_PARAM_COUNT;
407+
}
407408

408409
RETURN_LONG(snmp_get_quick_print() ? 1 : 0);
409410
}
@@ -418,6 +419,7 @@ PHP_FUNCTION(snmp_set_quick_print)
418419

419420
if (zend_parse_parameters(argc, "l", &a1) == FAILURE)
420421
return;
422+
421423
snmp_set_quick_print((int)a1);
422424
}
423425
/* }}} */

ext/sockets/sockets.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ PHP_FUNCTION(socket_fd_alloc)
397397
{
398398
php_fd_set *php_fd;
399399

400-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
401-
return;
400+
if (ZEND_NUM_ARGS() != 0) {
401+
WRONG_PARAM_COUNT;
402+
}
402403

403404
php_fd = (php_fd_set*)emalloc(sizeof(php_fd_set));
404405

ext/standard/basic_functions.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,9 @@ PHP_FUNCTION(settype)
13161316
Get the name of the owner of the current PHP script */
13171317
PHP_FUNCTION(get_current_user)
13181318
{
1319-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
1320-
return;
1319+
if (ZEND_NUM_ARGS() != 0) {
1320+
WRONG_PARAM_COUNT;
1321+
}
13211322

13221323
RETURN_STRING(php_get_current_user(), 1);
13231324
}
@@ -1343,7 +1344,6 @@ PHP_FUNCTION(get_cfg_var)
13431344
}
13441345
/* }}} */
13451346

1346-
13471347
/* {{{ proto bool set_magic_quotes_runtime(int new_setting)
13481348
Set the current active configuration setting of magic_quotes_runtime and return previous */
13491349
PHP_FUNCTION(set_magic_quotes_runtime)

ext/standard/head.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ PHP_FUNCTION(setcookie)
180180
Return true if headers have already been sent, false otherwise */
181181
PHP_FUNCTION(headers_sent)
182182
{
183+
if (ZEND_NUM_ARGS() != 0) {
184+
WRONG_PARAM_COUNT;
185+
}
186+
183187
if (SG(headers_sent)) {
184188
RETURN_TRUE;
185189
} else {

ext/standard/info.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,9 @@ PHP_FUNCTION(phpinfo)
476476
Return the current PHP version */
477477
PHP_FUNCTION(phpversion)
478478
{
479-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
480-
return;
479+
if (ZEND_NUM_ARGS() != 0) {
480+
WRONG_PARAM_COUNT;
481+
}
481482

482483
RETURN_STRING(PHP_VERSION, 1);
483484
}
@@ -506,8 +507,9 @@ PHP_FUNCTION(phpcredits)
506507
Return the special ID used to request the PHP logo in phpinfo screens*/
507508
PHP_FUNCTION(php_logo_guid)
508509
{
509-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
510-
return;
510+
if (ZEND_NUM_ARGS() != 0) {
511+
WRONG_PARAM_COUNT;
512+
}
511513

512514
RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
513515
}
@@ -517,8 +519,9 @@ PHP_FUNCTION(php_logo_guid)
517519
Return the special ID used to request the PHP logo in phpinfo screens*/
518520
PHP_FUNCTION(php_egg_logo_guid)
519521
{
520-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
521-
return;
522+
if (ZEND_NUM_ARGS() != 0) {
523+
WRONG_PARAM_COUNT;
524+
}
522525

523526
RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
524527
}
@@ -528,8 +531,9 @@ PHP_FUNCTION(php_egg_logo_guid)
528531
Return the special ID used to request the Zend logo in phpinfo screens*/
529532
PHP_FUNCTION(zend_logo_guid)
530533
{
531-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
532-
return;
534+
if (ZEND_NUM_ARGS() != 0) {
535+
WRONG_PARAM_COUNT;
536+
}
533537

534538
RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
535539
}
@@ -539,8 +543,9 @@ PHP_FUNCTION(zend_logo_guid)
539543
Return the current SAPI module name */
540544
PHP_FUNCTION(php_sapi_name)
541545
{
542-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
543-
return;
546+
if (ZEND_NUM_ARGS() != 0) {
547+
WRONG_PARAM_COUNT;
548+
}
544549

545550
if (sapi_module.name) {
546551
RETURN_STRING(sapi_module.name, 1);
@@ -555,8 +560,9 @@ PHP_FUNCTION(php_sapi_name)
555560
Return information about the system PHP was built on */
556561
PHP_FUNCTION(php_uname)
557562
{
558-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
559-
return;
563+
if (ZEND_NUM_ARGS() != 0) {
564+
WRONG_PARAM_COUNT;
565+
}
560566

561567
RETURN_STRING(php_get_uname(), 0);
562568
}

ext/standard/rand.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ PHP_FUNCTION(mt_rand)
329329
Returns the maximum value a random number can have */
330330
PHP_FUNCTION(getrandmax)
331331
{
332+
if (ZEND_NUM_ARGS() != 0) {
333+
WRONG_PARAM_COUNT;
334+
}
335+
332336
return_value->type = IS_LONG;
333337
return_value->value.lval = PHP_RAND_MAX;
334338
}
@@ -338,6 +342,10 @@ PHP_FUNCTION(getrandmax)
338342
Returns the maximum value a random number from Mersenne Twister can have */
339343
PHP_FUNCTION(mt_getrandmax)
340344
{
345+
if (ZEND_NUM_ARGS() != 0) {
346+
WRONG_PARAM_COUNT;
347+
}
348+
341349
return_value->type = IS_LONG;
342350
/*
343351
* Melo: it could be 2^^32 but we only use 2^^31 to maintain

0 commit comments

Comments
 (0)