summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2010-07-20 15:07:36 -0300
committerDavi Arnaut <davi.arnaut@oracle.com>2010-07-20 15:07:36 -0300
commitc96b249fc3912f7a86f885cc62da1a3eeed537c6 (patch)
tree3be217b0b2b0e9c76e6f41abe8c7fa3aeb35d373 /mysys
parentd676c3ff0eef8613ac689df8ed07ecdd0a39817b (diff)
downloadmariadb-git-c96b249fc3912f7a86f885cc62da1a3eeed537c6.tar.gz
Bug#45288: pb2 returns a lot of compilation warnings on linux
Fix warnings flagged by the new warning option -Wunused-but-set-variable that was added to GCC 4.6 and that is enabled by -Wunused and -Wall. The option causes a warning whenever a local variable is assigned to but is later unused. It also warns about meaningless pointer dereferences.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/errors.c6
-rw-r--r--mysys/mf_iocache.c11
-rw-r--r--mysys/my_copy.c20
-rw-r--r--mysys/my_redel.c24
4 files changed, 47 insertions, 14 deletions
diff --git a/mysys/errors.c b/mysys/errors.c
index 8d3303cac9f..a5ad4a956ab 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -49,7 +49,9 @@ const char * NEAR globerrs[GLOBERRS]=
"Can't sync file '%s' to disk (Errcode: %d)",
"Collation '%s' is not a compiled collation and is not specified in the '%s' file",
"File '%s' not found (Errcode: %d)",
- "File '%s' (fileno: %d) was not closed"
+ "File '%s' (fileno: %d) was not closed",
+ "Can't change ownership of the file '%s' (Errcode: %d)",
+ "Can't change permissions of the file '%s' (Errcode: %d)",
};
void init_glob_errs(void)
@@ -90,6 +92,8 @@ void init_glob_errs()
EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file";
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)";
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
+ EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)";
+ EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)";
}
#endif
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 1a47982b221..e9b947b04a6 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -1701,16 +1701,19 @@ int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count,
#endif
-int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
+int my_b_flush_io_cache(IO_CACHE *info,
+ int need_append_buffer_lock __attribute__((unused)))
{
size_t length;
- my_bool append_cache;
my_off_t pos_in_file;
+ my_bool append_cache= (info->type == SEQ_READ_APPEND);
DBUG_ENTER("my_b_flush_io_cache");
DBUG_PRINT("enter", ("cache: 0x%lx", (long) info));
- if (!(append_cache = (info->type == SEQ_READ_APPEND)))
- need_append_buffer_lock=0;
+#ifdef THREAD
+ if (!append_cache)
+ need_append_buffer_lock= 0;
+#endif
if (info->type == WRITE_CACHE || append_cache)
{
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 418e2b6f8a2..d0c1fc29229 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -16,6 +16,7 @@
#include "mysys_priv.h"
#include <my_dir.h> /* for stat */
#include <m_string.h>
+#include "mysys_err.h"
#if defined(HAVE_UTIME_H)
#include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
@@ -56,7 +57,6 @@ int my_copy(const char *from, const char *to, myf MyFlags)
File from_file,to_file;
uchar buff[IO_SIZE];
MY_STAT stat_buff,new_stat_buff;
- int res;
DBUG_ENTER("my_copy");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
@@ -102,9 +102,23 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
- res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */
+ /* Copy modes */
+ if (chmod(to, stat_buff.st_mode & 07777))
+ {
+ my_errno= errno;
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ goto err;
+ }
#if !defined(__WIN__) && !defined(__NETWARE__)
- res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */
+ /* Copy ownership */
+ if (chown(to, stat_buff.st_uid,stat_buff.st_gid))
+ {
+ my_errno= errno;
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ goto err;
+ }
#endif
#if !defined(VMS) && !defined(__ZTC__)
if (MyFlags & MY_COPYTIME)
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 6521253f949..4013c5c8323 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -76,11 +76,8 @@ end:
int my_copystat(const char *from, const char *to, int MyFlags)
{
struct stat statbuf;
-#if !defined(__WIN__) && !defined(__NETWARE__)
- int res;
-#endif
- if (stat((char*) from, &statbuf))
+ if (stat(from, &statbuf))
{
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
@@ -89,7 +86,15 @@ int my_copystat(const char *from, const char *to, int MyFlags)
}
if ((statbuf.st_mode & S_IFMT) != S_IFREG)
return 1;
- VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
+
+ /* Copy modes */
+ if (chmod(to, statbuf.st_mode & 07777))
+ {
+ my_errno= errno;
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ return -1;
+ }
#if !defined(__WIN__) && !defined(__NETWARE__)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
@@ -97,7 +102,14 @@ int my_copystat(const char *from, const char *to, int MyFlags)
if (MyFlags & MY_LINK_WARNING)
my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
}
- res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */
+ /* Copy ownership */
+ if (chown(to, statbuf.st_uid, statbuf.st_gid))
+ {
+ my_errno= errno;
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ return -1;
+ }
#endif /* !__WIN__ && !__NETWARE__ */
#ifndef VMS