[libdvdcss-devel] [PATCH] Check the return values of write() calls.
Diego Biurrun
diego at biurrun.de
Tue Mar 12 10:54:35 CET 2013
Fixes the following two warnings:
src/libdvdcss.c:380:18: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
src/css.c:275:18: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
---
src/css.c | 8 ++++++--
src/libdvdcss.c | 6 +++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/css.c b/src/css.c
index 935b7b2..2d13d5e 100644
--- a/src/css.c
+++ b/src/css.c
@@ -266,13 +266,17 @@ 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];
+ ssize_t len = KEY_SIZE * 3 + 2;
+ char psz_key[len];
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 );
+ if( write( i_fd, psz_key, len - 1 ) < len - 1 )
+ {
+ return -1;
+ }
close( i_fd );
}
}
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 2a1a5bb..c922bef 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -377,7 +377,11 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
if( i_fd >= 0 )
{
- write( i_fd, psz_tag, strlen(psz_tag) );
+ ssize_t len = strlen(psz_tag);
+ if( write( i_fd, psz_tag, len ) < len )
+ {
+ return NULL;
+ }
close( i_fd );
}
}
--
1.7.9.5
More information about the libdvdcss-devel
mailing list