[WIP,1/6] media: vidtv: extract the initial CRC value to into a #define

Message ID 20200929032625.1548909-1-dwlsalmeida@gmail.com (mailing list archive)
State Superseded, archived
Headers
Series [WIP,1/6] media: vidtv: extract the initial CRC value to into a #define |

Commit Message

Daniel Almeida Sept. 29, 2020, 3:26 a.m. UTC
  From: Daniel W. S. Almeida <dwlsalmeida@gmail.com>

The same constant (0xffffffff) is used in three different functions.

Extract it into a #define to avoid repetition.

Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
---
 drivers/media/test-drivers/vidtv/vidtv_psi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Mauro Carvalho Chehab Sept. 29, 2020, 5:19 a.m. UTC | #1
Em Tue, 29 Sep 2020 00:26:20 -0300
"Daniel W. S. Almeida" <dwlsalmeida@gmail.com> escreveu:

> From: Daniel W. S. Almeida <dwlsalmeida@gmail.com>

On a very quick look, patches seem good. Why did you mark them as WIP?

Next time, please add a patch 0, specially when you tag something as
WIP, or RFC.

> 
> The same constant (0xffffffff) is used in three different functions.

This one at least seems to be ready for merging ;-)

Regards,
Mauro
> 
> Extract it into a #define to avoid repetition.
> 
> Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
> ---
>  drivers/media/test-drivers/vidtv/vidtv_psi.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/test-drivers/vidtv/vidtv_psi.c
> index 3151b300a91b..a24e84adc8ce 100644
> --- a/drivers/media/test-drivers/vidtv/vidtv_psi.c
> +++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c
> @@ -30,6 +30,7 @@
>  
>  #define CRC_SIZE_IN_BYTES 4
>  #define MAX_VERSION_NUM 32
> +#define INITIAL_CRC 0xffffffff
>  
>  static const u32 CRC_LUT[256] = {
>  	/* from libdvbv5 */
> @@ -794,7 +795,7 @@ u32 vidtv_psi_pat_write_into(struct vidtv_psi_pat_write_args args)
>  	/* the number of bytes written by this function */
>  	u32 nbytes = 0;
>  	const u16 pat_pid = VIDTV_PAT_PID;
> -	u32 crc = 0xffffffff;
> +	u32 crc = INITIAL_CRC;
>  
>  	struct vidtv_psi_table_pat_program *p = args.pat->program;
>  
> @@ -990,7 +991,7 @@ u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
>  {
>  	/* the number of bytes written by this function */
>  	u32 nbytes = 0;
> -	u32 crc = 0xffffffff;
> +	u32 crc = INITIAL_CRC;
>  
>  	struct vidtv_psi_desc *table_descriptor   = args.pmt->descriptor;
>  	struct vidtv_psi_table_pmt_stream *stream = args.pmt->stream;
> @@ -1143,7 +1144,7 @@ u32 vidtv_psi_sdt_write_into(struct vidtv_psi_sdt_write_args args)
>  	u32 nbytes  = 0;
>  	u16 sdt_pid = VIDTV_SDT_PID;  /* see ETSI EN 300 468 v1.15.1 p. 11 */
>  
> -	u32 crc = 0xffffffff;
> +	u32 crc = INITIAL_CRC;
>  
>  	struct vidtv_psi_table_sdt_service *service = args.sdt->service;
>  	struct vidtv_psi_desc *service_desc = (args.sdt->service) ?



Thanks,
Mauro
  
Daniel Almeida Sept. 29, 2020, 9:30 a.m. UTC | #2
Hi Mauro!

> Next time, please add a patch 0, specially when you tag something as
> WIP, or RFC.

Sorry about that :)

These are almost good but I came across some weird kasan output.

Can you test this series in a kernel with kasan instrumentation turned on?

Should apply just fine on top of your latest changes in mchehab-experimental/vidtv

-- thanks
-- Daniel
  
Mauro Carvalho Chehab Sept. 29, 2020, 2:51 p.m. UTC | #3
Em Tue, 29 Sep 2020 06:30:56 -0300
"Daniel W. S. Almeida" <dwlsalmeida@gmail.com> escreveu:

> Hi Mauro!
> 
> > Next time, please add a patch 0, specially when you tag something as
> > WIP, or RFC.  
> 
> Sorry about that :)
> 
> These are almost good but I came across some weird kasan output.
> 
> Can you test this series in a kernel with kasan instrumentation turned on?
> 
> Should apply just fine on top of your latest changes in mchehab-experimental/vidtv

I'm currently focusing preparing some things for the merge window.

I can try to test them after it.

Btw, before testing those patches, you should test with KASAN and
with the memory leak detector if everything is being de-allocated
when the drivers are removed from the memory.

If you find something wrong there, I suggest you to fix the
found issues before applying the new NIT and EDT tables support,
as it may help to check what it could be happening after the
patches.

Thanks,
Mauro
  

Patch

diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/test-drivers/vidtv/vidtv_psi.c
index 3151b300a91b..a24e84adc8ce 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_psi.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c
@@ -30,6 +30,7 @@ 
 
 #define CRC_SIZE_IN_BYTES 4
 #define MAX_VERSION_NUM 32
+#define INITIAL_CRC 0xffffffff
 
 static const u32 CRC_LUT[256] = {
 	/* from libdvbv5 */
@@ -794,7 +795,7 @@  u32 vidtv_psi_pat_write_into(struct vidtv_psi_pat_write_args args)
 	/* the number of bytes written by this function */
 	u32 nbytes = 0;
 	const u16 pat_pid = VIDTV_PAT_PID;
-	u32 crc = 0xffffffff;
+	u32 crc = INITIAL_CRC;
 
 	struct vidtv_psi_table_pat_program *p = args.pat->program;
 
@@ -990,7 +991,7 @@  u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
 {
 	/* the number of bytes written by this function */
 	u32 nbytes = 0;
-	u32 crc = 0xffffffff;
+	u32 crc = INITIAL_CRC;
 
 	struct vidtv_psi_desc *table_descriptor   = args.pmt->descriptor;
 	struct vidtv_psi_table_pmt_stream *stream = args.pmt->stream;
@@ -1143,7 +1144,7 @@  u32 vidtv_psi_sdt_write_into(struct vidtv_psi_sdt_write_args args)
 	u32 nbytes  = 0;
 	u16 sdt_pid = VIDTV_SDT_PID;  /* see ETSI EN 300 468 v1.15.1 p. 11 */
 
-	u32 crc = 0xffffffff;
+	u32 crc = INITIAL_CRC;
 
 	struct vidtv_psi_table_sdt_service *service = args.sdt->service;
 	struct vidtv_psi_desc *service_desc = (args.sdt->service) ?