<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Rémi,</p>
<p>On 2017-05-18 19:05, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Le torstaina 18. toukokuuta 2017, 12.19.37 EEST Filip Roséen a écrit :</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> The address of this function is passed to bsearch, and bsearch accepts
 a pointer to int(void const*,void const*), meaning that the previous
 prototype would generate a warning (and strictly speaking was not
 valid).
 ---
  modules/demux/mpeg/ts_pid.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/modules/demux/mpeg/ts_pid.c b/modules/demux/mpeg/ts_pid.c
 index 27779a04d8..eed60a3a28 100644
 --- a/modules/demux/mpeg/ts_pid.c
 +++ b/modules/demux/mpeg/ts_pid.c
 @@ -65,7 +65,7 @@ struct searchkey
      ts_pid_t **pp_last;
  };

 -static int ts_bsearch_searchkey_Compare( void *key, void *other )
 +static int ts_bsearch_searchkey_Compare( const void *key, const void *other
 ) {
      struct searchkey *p_key = (struct searchkey *) key;
      ts_pid_t *p_pid = *((ts_pid_t **) other);</code></pre>
</blockquote>
<pre><code> Removing the const qualifier via cast is not a good practice, even if it is 
 legal.</code></pre>
</blockquote>
<p>I agree, and while we are talking about that function I realized that I forgot to send a follow-up email that talks about how it is doing a lot of things that it is not supposed to.</p>
<p>For one, as can be seen by <a href="http://git.videolan.org/?p=vlc.git;a=blob;f=modules/demux/mpeg/ts_pid.c;h=27779a04d814b78cb675e37ebfd017b53d96c3e5;hb=HEAD#l134">this part of the implementation</a>, it is making assumptions about the implementation of <code>bsearch</code> that are not guaranteed to be true in practice - at least I do not know what wording in the standard that states that the search should stop at what would be the insertion point.</p>
<p>I am not sure if a ticket should be created about it, or if this email is sufficient enough to actually warrant a fixup of the actual code in question. Honestly, I was too tired to fix it while I fixed the mentioned diagnostic (its the only reason I didn’t do it as part of the commit).</p>
<p>Best Regards,<br />
Filip</p>
</body>
</html>