[libdvdcss-devel] [PATCH 1/2] css: Factorize psz_key array sizes into a common #define.
Diego Biurrun
diego at biurrun.de
Fri Mar 15 15:55:41 CET 2013
---
src/css.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/css.c b/src/css.c
index 935b7b2..a8b8e0e 100644
--- a/src/css.c
+++ b/src/css.c
@@ -61,6 +61,8 @@
#include "ioctl.h"
#include "device.h"
+#define PSZ_KEY_SIZE (KEY_SIZE * 3)
+
/*****************************************************************************
* Local prototypes
*****************************************************************************/
@@ -217,12 +219,12 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
if( i_fd >= 0 )
{
- char psz_key[KEY_SIZE * 3];
+ char psz_key[PSZ_KEY_SIZE];
unsigned int k0, k1, k2, k3, k4;
- psz_key[KEY_SIZE * 3 - 1] = '\0';
+ psz_key[PSZ_KEY_SIZE - 1] = '\0';
- if( read( i_fd, psz_key, KEY_SIZE * 3 - 1 ) == KEY_SIZE * 3 - 1
+ if( read( i_fd, psz_key, PSZ_KEY_SIZE - 1 ) == PSZ_KEY_SIZE - 1
&& sscanf( psz_key, "%x:%x:%x:%x:%x",
&k0, &k1, &k2, &k3, &k4 ) == 5 )
{
@@ -266,13 +268,13 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 );
if( i_fd >= 0 )
{
- char psz_key[KEY_SIZE * 3 + 2];
+ char psz_key[PSZ_KEY_SIZE + 2];
sprintf( psz_key, "%02x:%02x:%02x:%02x:%02x\r\n",
p_title_key[0], p_title_key[1], p_title_key[2],
p_title_key[3], p_title_key[4] );
- write( i_fd, psz_key, KEY_SIZE * 3 + 1 );
+ write( i_fd, psz_key, PSZ_KEY_SIZE + 1 )
close( i_fd );
}
}
--
1.7.9.5
More information about the libdvdcss-devel
mailing list