From 8913f82c266ed35bdf431d61e89ee9eb682f2192 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 14 Jan 2012 18:07:41 +0000
Subject: [PATCH] - Fixed compiler warning for unreferenced ret in md_file()
when POLARSSL_FS_IO not declared
---
include/polarssl/error.h | 4 ++--
include/polarssl/md.h | 3 +--
library/error.c | 6 ++----
library/md.c | 10 +++++-----
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/include/polarssl/error.h b/include/polarssl/error.h
index 78ad36255..9c1707105 100644
--- a/include/polarssl/error.h
+++ b/include/polarssl/error.h
@@ -72,8 +72,8 @@
* X509 2 21
* DHM 3 6
* RSA 4 9
- * MD 5 1
- * CIPER 6 1
+ * MD 5 4
+ * CIPHER 6 5
* SSL 7 30
*
* Module dependent error code (5 bits 0x.08.-0x.F8.)
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index f62ef2038..88596cb04 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -42,8 +42,7 @@
#define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
#define POLARSSL_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
#define POLARSSL_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
-#define POLARSSL_ERR_MD_FILE_OPEN_FAILED -0x5200 /**< Opening of file failed. */
-#define POLARSSL_ERR_MD_FILE_READ_FAILED -0x5280 /**< Failure when reading from file. */
+#define POLARSSL_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
typedef enum {
POLARSSL_MD_NONE=0,
diff --git a/library/error.c b/library/error.c
index 5dcd17580..9bc503429 100644
--- a/library/error.c
+++ b/library/error.c
@@ -177,10 +177,8 @@ void error_strerror( int ret, char *buf, size_t buflen )
snprintf( buf, buflen, "MD - Bad input parameters to function" );
if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) )
snprintf( buf, buflen, "MD - Failed to allocate memory" );
- if( use_ret == -(POLARSSL_ERR_MD_FILE_OPEN_FAILED) )
- snprintf( buf, buflen, "MD - Opening of file failed" );
- if( use_ret == -(POLARSSL_ERR_MD_FILE_READ_FAILED) )
- snprintf( buf, buflen, "MD - Failure when reading from file" );
+ if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) )
+ snprintf( buf, buflen, "MD - Opening or reading of file failed" );
#endif /* POLARSSL_MD_C */
#if defined(POLARSSL_PEM_C)
diff --git a/library/md.c b/library/md.c
index 51fb82e15..d15bf1dca 100644
--- a/library/md.c
+++ b/library/md.c
@@ -222,19 +222,19 @@ int md( const md_info_t *md_info, const unsigned char *input, size_t ilen,
int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
{
+#if defined(POLARSSL_FS_IO)
int ret;
+#endif
if( md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
#if defined(POLARSSL_FS_IO)
ret = md_info->file_func( path, output );
- if( ret == 2 )
- return POLARSSL_ERR_MD_FILE_OPEN_FAILED;
- if( ret == 3 )
- return POLARSSL_ERR_MD_FILE_READ_FAILED;
+ if( ret != 0 )
+ return( POLARSSL_ERR_MD_FILE_IO_ERROR + ret );
- return ret;
+ return( ret );
#else
((void) path);
((void) output);