Accepting request 595812 from home:wanghaisu:branches:Base:System

bsc#1084630, compat to gcc8.

OBS-URL: https://build.opensuse.org/request/show/595812
OBS-URL: https://build.opensuse.org/package/show/Base:System/libstoragemgmt?expand=0&rev=44
This commit is contained in:
Martin Pluskal 2018-04-12 06:56:40 +00:00 committed by Git OBS Bridge
parent 36c43422f7
commit a395ab7f2f
3 changed files with 271 additions and 1 deletions

258
compat-gcc8.patch Normal file
View File

@ -0,0 +1,258 @@
commit edbd5fed3cb5f4f48dcc7ee97f601d2ea3537911
Author: Gris Ge <fge@redhat.com>
Date: Fri Mar 23 20:38:55 2018 +0800
Fix GCC 8 compile warnings.
* Fix '-Werror=format-truncation' warning by increase the buffer size.
* Fix '-Werror=cast-function-type' warning by disable it for Python c
extension, reason:
https://stackoverflow.com/questions/10264080/python-c-extension-why-are-methods-that-use-keyword-arguments-cast-to-pycfunct
diff --git a/c_binding/libsg.c b/c_binding/libsg.c
index 75ee39d..4689369 100644
--- a/c_binding/libsg.c
+++ b/c_binding/libsg.c
@@ -367,8 +367,9 @@ static int _sg_io_open(char *err_msg, const char *disk_path, int *fd,
* The 'sense_key' is the output pointer.
* Return 0 if sense_key is _T10_SPC_SENSE_KEY_NO_SENSE or
* _T10_SPC_SENSE_KEY_RECOVERED_ERROR, return -1 otherwise.
+ * sense_err_msg should be char[_LSM_ERR_MSG_LEN / 2]
*/
-static int _check_sense_data(char *err_msg, uint8_t *sense_data,
+static int _check_sense_data(char *sense_err_msg, uint8_t *sense_data,
uint8_t *sense_key);
static int _extract_ata_sense_data(char *err_msg, uint8_t *sense_data,
@@ -485,14 +486,14 @@ int _sg_io_vpd(char *err_msg, int fd, uint8_t page_code, uint8_t *data)
int rc_vpd_00 = 0;
char strerr_buff[_LSM_ERR_MSG_LEN];
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
ssize_t data_len = 0;
assert(err_msg != NULL);
assert(fd >= 0);
assert(data != NULL);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
switch(page_code) {
case _SG_T10_SPC_VPD_ATA_INFO:
@@ -812,7 +813,7 @@ static int _sg_io_open(char *err_msg, const char *disk_path, int *fd, int oflag)
return rc;
}
-static int _check_sense_data(char *err_msg, uint8_t *sense_data,
+static int _check_sense_data(char *sense_err_msg, uint8_t *sense_data,
uint8_t *sense_key)
{
int rc = -1;
@@ -856,8 +857,9 @@ static int _check_sense_data(char *err_msg, uint8_t *sense_data,
rc = 0;
goto out;
default:
- _lsm_err_msg_set(err_msg, "Got unknown sense data response code %02x",
- sense_hdr->response_code);
+ snprintf(sense_err_msg, _LSM_ERR_MSG_LEN / 2,
+ "Got unknown sense data response code %02x",
+ sense_hdr->response_code);
goto out;
}
/* TODO(Gris Ge): Handle ADDITIONAL SENSE CODE field and ADDITIONAL SENSE
@@ -879,11 +881,12 @@ static int _check_sense_data(char *err_msg, uint8_t *sense_data,
/* As sense_key is 4 bytes and we covered all 16 values in
* _T10_SPC_SENSE_KEY_STR, there will be no out of index error.
*/
- _lsm_err_msg_set(err_msg, "Got SCSI sense data, key %s(0x%02x), "
- "ADDITIONAL SENSE CODE 0x%02x, ADDITIONAL SENSE CODE "
- "QUALIFIER 0x%02x, all sense data in hex: %s",
- _T10_SPC_SENSE_KEY_STR[*sense_key], *sense_key,
- asc, ascq, sense_data_str);
+ snprintf(sense_err_msg, _LSM_ERR_MSG_LEN / 2 ,
+ "Got SCSI sense data, key %s(0x%02x), "
+ "ADDITIONAL SENSE CODE 0x%02x, ADDITIONAL SENSE CODE "
+ "QUALIFIER 0x%02x, all sense data in hex: %s",
+ _T10_SPC_SENSE_KEY_STR[*sense_key], *sense_key,
+ asc, ascq, sense_data_str);
}
out:
@@ -921,13 +924,13 @@ int _sg_io_recv_diag(char *err_msg, int fd, uint8_t page_code, uint8_t *data)
char strerr_buff[_LSM_ERR_MSG_LEN];
uint8_t sense_data[_T10_SPC_SENSE_DATA_MAX_LENGTH];
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
assert(err_msg != NULL);
assert(fd >= 0);
assert(data != NULL);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
/* SPC-5 rev 07, Table 219 - RECEIVE DIAGNOSTIC RESULTS command */
cdb[0] = RECEIVE_DIAGNOSTIC; /* OPERATION CODE */
@@ -975,14 +978,14 @@ int _sg_io_send_diag(char *err_msg, int fd, uint8_t *data, uint16_t data_len)
char strerr_buff[_LSM_ERR_MSG_LEN];
uint8_t sense_data[_T10_SPC_SENSE_DATA_MAX_LENGTH];
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
assert(err_msg != NULL);
assert(fd >= 0);
assert(data != NULL);
assert(data_len > 0);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
/* SPC-5 rev 07, Table 219 - RECEIVE DIAGNOSTIC RESULTS command */
cdb[0] = SEND_DIAGNOSTIC; /* OPERATION CODE */
@@ -1078,7 +1081,7 @@ int _sg_io_mode_sense(char *err_msg, int fd, uint8_t page_code,
int ioctl_errno = 0;
char strerr_buff[_LSM_ERR_MSG_LEN];
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
struct _sg_t10_mode_para_hdr *mode_hdr = NULL;
uint16_t block_dp_len = 0;
uint16_t mode_data_len = 0;
@@ -1087,7 +1090,7 @@ int _sg_io_mode_sense(char *err_msg, int fd, uint8_t page_code,
assert(fd >= 0);
assert(data != NULL);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
memset(data, 0, _SG_T10_SPC_MODE_SENSE_MAX_LEN);
/* SPC-5 Table 171 - MODE SENSE(10) command */
@@ -1257,7 +1260,7 @@ static int _sg_log_sense(char *err_msg, int fd, uint8_t page_code,
int ioctl_errno = 0;
char strerr_buff[_LSM_ERR_MSG_LEN];
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
struct _sg_t10_log_para_hdr *log_hdr = NULL;
uint16_t log_data_len = 0;
@@ -1265,7 +1268,7 @@ static int _sg_log_sense(char *err_msg, int fd, uint8_t page_code,
assert(fd >= 0);
assert(data != NULL);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
memset(cdb, 0, _T10_SPC_LOG_SENSE_CMD_LEN);
cdb[0] = LOG_SENSE;
@@ -1320,14 +1323,14 @@ int _sg_request_sense(char *err_msg, int fd, uint8_t *returned_sense_data)
uint8_t sense_data[_T10_SPC_SENSE_DATA_MAX_LENGTH];
int ioctl_errno = 0;
uint8_t sense_key = _T10_SPC_SENSE_KEY_NO_SENSE;
- char sense_err_msg[_LSM_ERR_MSG_LEN];
+ char sense_err_msg[_LSM_ERR_MSG_LEN / 2];
char strerr_buff[_LSM_ERR_MSG_LEN];
assert(err_msg != NULL);
assert(fd >= 0);
assert(returned_sense_data != NULL);
- memset(sense_err_msg, 0, _LSM_ERR_MSG_LEN);
+ memset(sense_err_msg, 0, sizeof(sense_err_msg));
memset(cdb, 0, _T10_SPC_REQUEST_SENSE_CMD_LEN);
cdb[0] = REQUEST_SENSE;
diff --git a/c_binding/utils.h b/c_binding/utils.h
index 15d0c97..f63b6e3 100644
--- a/c_binding/utils.h
+++ b/c_binding/utils.h
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <stdbool.h>
-#define _LSM_ERR_MSG_LEN 1024
+#define _LSM_ERR_MSG_LEN 4096
#define _good(rc, rc_val, out) \
do { \
diff --git a/plugin/simc/db.c b/plugin/simc/db.c
index 7b3613e..aad9f30 100644
--- a/plugin/simc/db.c
+++ b/plugin/simc/db.c
@@ -768,7 +768,7 @@ void _db_sql_trans_rollback(sqlite3 *db)
int _db_data_add(char *err_msg, sqlite3 *db, const char *table_name, ...)
{
int rc = LSM_ERR_OK;
- char sql_cmd[_BUFF_SIZE];
+ char sql_cmd[_BUFF_SIZE * 4];
char keys_str[_BUFF_SIZE];
char values_str[_BUFF_SIZE];
const char *key_str = NULL;
diff --git a/plugin/simc/nfs_ops.c b/plugin/simc/nfs_ops.c
index 4d7235d..b8bcde5 100644
--- a/plugin/simc/nfs_ops.c
+++ b/plugin/simc/nfs_ops.c
@@ -159,7 +159,7 @@ int nfs_export_fs(lsm_plugin_ptr c, const char *fs_id, const char *export_path,
uint64_t sim_fs_id = 0;
uint64_t sim_exp_id = 0;
char tmp_export_path[_BUFF_SIZE];
- char vpd83[_BUFF_SIZE];
+ char vpd83[_VPD_83_LEN];
_UNUSED(flags);
_lsm_err_msg_clear(err_msg);
diff --git a/plugin/simc/san_ops.c b/plugin/simc/san_ops.c
index 57161ad..2c9fbde 100644
--- a/plugin/simc/san_ops.c
+++ b/plugin/simc/san_ops.c
@@ -1111,7 +1111,7 @@ int volume_unmask(lsm_plugin_ptr c, lsm_access_group *group, lsm_volume *volume,
char err_msg[_LSM_ERR_MSG_LEN];
char condition[_BUFF_SIZE];
struct _vector *vec = NULL;
- char sql_cmd_check_mask[_BUFF_SIZE];
+ char sql_cmd_check_mask[_BUFF_SIZE * 4];
_UNUSED(flags);
_lsm_err_msg_clear(err_msg);
diff --git a/plugin/simc/utils.h b/plugin/simc/utils.h
index 6914e59..90bb54a 100644
--- a/plugin/simc/utils.h
+++ b/plugin/simc/utils.h
@@ -36,7 +36,7 @@ struct _simc_private_data {
#define _UNUSED(x) (void)(x)
#define _MD5_HASH_STR_LEN MD5_DIGEST_LENGTH * 2 + 1
-#define _LSM_ERR_MSG_LEN 1024
+#define _LSM_ERR_MSG_LEN 4096
#define _VPD_83_LEN 17
/* ^ 6h IEEE Registered ID which it 16 bits hex string. */
@@ -63,8 +63,8 @@ struct _simc_private_data {
#define _snprintf_buff(err_msg, rc, out, buff, format, ...) \
do { \
if (buff != NULL) \
- snprintf(buff, _BUFF_SIZE, format, ##__VA_ARGS__); \
- if (strlen(buff) == _BUFF_SIZE - 1 ) { \
+ snprintf(buff, sizeof(buff)/sizeof(char), format, ##__VA_ARGS__); \
+ if (strlen(buff) == sizeof(buff)/sizeof(char) - 1 ) { \
rc = LSM_ERR_PLUGIN_BUG; \
_lsm_err_msg_set(err_msg, "Buff too small"); \
goto out; \
diff --git a/python_binding/Makefile.am b/python_binding/Makefile.am
index 56a4710..cacb6a0 100644
--- a/python_binding/Makefile.am
+++ b/python_binding/Makefile.am
@@ -21,7 +21,8 @@ endif
pyexec_LTLIBRARIES = lsm/_clib.la
pyexecdir = $(pythondir)/lsm
-lsm__clib_la_CFLAGS = $(PYTHON_CFLAGS) -I$(top_srcdir)/c_binding/include
+lsm__clib_la_CFLAGS = $(PYTHON_CFLAGS) -I$(top_srcdir)/c_binding/include \
+ -Wno-cast-function-type
lsm__clib_la_SOURCES = lsm/_clib.c
lsm__clib_la_LDFLAGS = $(PYTHON_LIBS) \
-module -avoid-version -export-symbols-regex \

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Tue Mar 27 08:27:39 UTC 2018 - nwang@suse.com
- bsc#1084630, compat to gcc8
Enlarge the err_msg to avoid [-Werror=format-truncation=]
'-Wno-cast-function-type' for python c building
Add automake to build requires in spec file.
- Add patch compat-gcc8.patch
-------------------------------------------------------------------
Tue Dec 19 05:43:41 UTC 2017 - nwang@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package libstoragemgmt
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -34,6 +34,8 @@ License: LGPL-2.1+ and GPL-2.0+
Group: System/Libraries
Url: https://github.com/libstorage/libstoragemgmt
Source0: https://github.com/libstorage/libstoragemgmt/releases/download/%{version}/%{name}-%{version}.tar.gz
Patch0: compat-gcc8.patch
BuildRequires: automake
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libconfig-devel
@ -260,6 +262,7 @@ storage.
%prep
%setup -q
%patch0 -p1
%build
%configure \