[libdvdcss-devel] css: Factorize psz_key array sizes into a common #define.

Diego Biurrun git at videolan.org
Sun Mar 17 13:49:01 CET 2013


libdvdcss | branch: master | Diego Biurrun <diego at biurrun.de> | Fri Mar 15 15:51:43 2013 +0100| [ade3847c6f77c4f413fd895120eed2086ff9caee] | committer: Diego Biurrun

css: Factorize psz_key array sizes into a common #define.

> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=ade3847c6f77c4f413fd895120eed2086ff9caee
---

 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 );
         }
     }



More information about the libdvdcss-devel mailing list