All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] compat/regex/regexec.c: Fix some sparse warnings
@ 2011-05-17 17:40 Ramsay Jones
  2011-05-17 22:52 ` Ævar Arnfjörð Bjarmason
  2011-05-18  4:04 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Ramsay Jones @ 2011-05-17 17:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list


In particular, sparse issues the following warnings:

        SP compat/regex/regex.c
    .../regexec.c:2329:40: warning: Using plain integer as NULL pointer
    .../regexec.c:2316:15: warning: symbol 'merge_state_with_log' was \
        not declared. Should it be static?
    .../regexec.c:2395:15: warning: symbol 'find_recover_state' was not \
        declared. Should it be static?

In order to fix the "symbol not declared" warnings (they are in fact
declared static earlier in the file), we simply add the static modifier
to the function definitions.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

Hi Junio,

Now that I'm building git with NO_REGEX=1 in my config.mak, I'm also
seeing these sparse warnings.

Note that the "symbol not declared" warnings actually highlight
a sparse bug; the earlier static function declarations should have
(effectively) 'transferred' the static modifier to the corresponding
function definition ...
[I have a testcase for this in my sparse repo, but I don't seem to have
found time to actually create a patch to fix this. :(]

ATB,
Ramsay Jones
 
 compat/regex/regexec.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
index 0194965..0cd6e0e 100644
--- a/compat/regex/regexec.c
+++ b/compat/regex/regexec.c
@@ -2313,7 +2313,7 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
 }
 
 /* Update the state_log if we need */
-re_dfastate_t *
+static re_dfastate_t *
 internal_function
 merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
 		      re_dfastate_t *next_state)
@@ -2326,7 +2326,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
       mctx->state_log[cur_idx] = next_state;
       mctx->state_log_top = cur_idx;
     }
-  else if (mctx->state_log[cur_idx] == 0)
+  else if (mctx->state_log[cur_idx] == NULL)
     {
       mctx->state_log[cur_idx] = next_state;
     }
@@ -2392,7 +2392,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
 /* Skip bytes in the input that correspond to part of a
    multi-byte match, then look in the log for a state
    from which to restart matching.  */
-re_dfastate_t *
+static re_dfastate_t *
 internal_function
 find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
 {
-- 
1.7.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/regex/regexec.c: Fix some sparse warnings
  2011-05-17 17:40 [PATCH] compat/regex/regexec.c: Fix some sparse warnings Ramsay Jones
@ 2011-05-17 22:52 ` Ævar Arnfjörð Bjarmason
  2011-05-18  4:04 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2011-05-17 22:52 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list

On Tue, May 17, 2011 at 19:40, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:
> In particular, sparse issues the following warnings:

Aside from this specific change, I think it's a problem that we pull
in external libraries, then apply patches to them that upstream would
probably want, don't tell upstream, and will inevitably have to deal
with conflict when we merge in new versions from upstream.

Maybe we should have some file with contact details for these compat
libraries, and try to resolve issues with upstream if we need to apply
patches like this one?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/regex/regexec.c: Fix some sparse warnings
  2011-05-17 17:40 [PATCH] compat/regex/regexec.c: Fix some sparse warnings Ramsay Jones
  2011-05-17 22:52 ` Ævar Arnfjörð Bjarmason
@ 2011-05-18  4:04 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2011-05-18  4:04 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: GIT Mailing-list

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

> In particular, sparse issues the following warnings:
>
>         SP compat/regex/regex.c

I'd rather leave stuff in compat/ that were imported from other people
intact, unless they are functionally wrong. We don't fix their styles
either.

Replacing our copy with newer versions that have fixed these issues from
upstreams is Ok, though.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-18  4:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17 17:40 [PATCH] compat/regex/regexec.c: Fix some sparse warnings Ramsay Jones
2011-05-17 22:52 ` Ævar Arnfjörð Bjarmason
2011-05-18  4:04 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.