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

Misc tweaks #492

Closed
wants to merge 15 commits into from
Closed

Misc tweaks #492

wants to merge 15 commits into from

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented May 29, 2024

No description provided.

cgzones added 11 commits May 28, 2024 22:16
Please GCC:

    In file included from /usr/include/php/20220829/Zend/zend.h:30,
                     from /usr/include/php/20220829/main/php.h:31,
                     from /usr/include/php/20220829/main/SAPI.h:20,
                     from src/php_snuffleupagus.h:37,
                     from src/sp_ifilter.c:1:
    src/sp_pcre_compat.h: In function 'sp_regexp_compile':
    src/sp_pcre_compat.h:38:36: warning: '__zend_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
       38 |   sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1);
          |                                    ^~~~~~~~~
    /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc'
      199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size)))
          |                                                                        ^~~~~
    src/sp_pcre_compat.h:38:36: note: earlier argument should specify number of elements, later size of each element
       38 |   sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1);
          |                                    ^~~~~~~~~
    /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc'
      199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size)))
          |                                                                        ^~~~~
Avoid the configure step each time during development.
Use the special value void as parameter for functions taking nor
argument.
Avoid missing prototype warnings by declaring variables and functions
that are only used in a single file static.
Adjusts casts to void dropping const qualifiers. This helps to avoid
mistakes, e.g. modifying string literals.

Also use size_t for length, similar to the upstream php interfaces.
Please static analyzers.
src/sp_utils.h Outdated Show resolved Hide resolved
src/sp_config_scanner.cached.c Show resolved Hide resolved
src/snuffleupagus.c Show resolved Hide resolved
@@ -172,7 +172,6 @@ static zval *get_unknown_type(const char *restrict value, zval *zvalue,
const sp_tree *const tree, bool is_param) {
if (ce) {
zvalue = get_entry_hashtable(&ce->constants_table, value, strlen(value));
ce = NULL;
Copy link
Owner

Choose a reason for hiding this comment

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

Did you check if ce isn't used in the callstack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ce is a local variable to this function, so an assignment here has no effect in any caller.

Copy link
Owner

Choose a reason for hiding this comment

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

ce is passed as a parameter to the function, it's not a local variable, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ce is a local copy of the address, so assigning NULL here has no effect to the address in the variable in the caller.

src/sp_utils.h Show resolved Hide resolved
Annotate the common logging function sp_log_msgf() with the format
attribute so compilers can check the used format string and passed
arguments for discrepancies.

Adjust the lineno printing by using %zu and the type size_t
consistently.
    src/sp_unserialize.c: In function 'zif_sp_unserialize':
    src/sp_unserialize.c:131:15: warning: unused variable 'orig_handler' [-Wunused-variable]
      131 |   zif_handler orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize"));
          |               ^~~~~~~~~~~~
/src/tests/disable_function/test.bla
/src/tests/disable_function/test.meh
/src/tests/disable_function/test.sim
/src/tests/eval_blacklist/test.bla

Copy link
Owner

Choose a reason for hiding this comment

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

Those files should be deleted by the testsuite, instead of being ignored here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried using --CLEAN--, but it seems php does not run the .clean.php snippet with the supplied configuration from --INI-- and thus the test borks, since the cleanup output is not empty but contains No configuration specified via sp.configuration_file.

@jvoisin
Copy link
Owner

jvoisin commented Jun 6, 2024

I cherry-picked all the commits except 1732735 and beaf7f0, thanks <3

@jvoisin jvoisin closed this Jun 6, 2024
@cgzones cgzones deleted the misc branch June 7, 2024 15:48
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