Skip to content

Commit

Permalink
Merge pull request #22 from chu11/warnings2
Browse files Browse the repository at this point in the history
Fix various compiler warnings
  • Loading branch information
chu11 committed Aug 29, 2023
2 parents c1e2a33 + 6b08e2c commit 552fde9
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 17 deletions.
19 changes: 8 additions & 11 deletions libltdl/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ host_triplet = @host@
@CONVENIENCE_LTDL_TRUE@am__append_3 = libltdlc.la
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../m4/libtool.m4 \
$(top_srcdir)/../m4/ltargz.m4 $(top_srcdir)/../m4/ltdl.m4 \
$(top_srcdir)/../m4/ltoptions.m4 \
$(top_srcdir)/../m4/ltsugar.m4 \
$(top_srcdir)/../m4/ltversion.m4 \
$(top_srcdir)/../m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
Expand Down Expand Up @@ -304,11 +303,9 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config-h.in \
$(top_srcdir)/../config/install-sh \
$(top_srcdir)/../config/ltmain.sh \
$(top_srcdir)/../config/missing ../config/compile \
../config/config.guess ../config/config.sub \
../config/depcomp ../config/install-sh \
../config/ltmain.sh \
../config/missing COPYING.LIB \
README lt__argz.c lt__dirent.c lt__strl.c
../config/config.guess ../config/config.sub ../config/depcomp \
../config/install-sh ../config/ltmain.sh ../config/missing \
COPYING.LIB README lt__argz.c lt__dirent.c lt__strl.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
Expand Down
3 changes: 3 additions & 0 deletions src/cerebrod/cerebrod_metric_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,11 @@ _send_message_now(int fd,
}
memset(mm, '\0', sizeof(struct cerebrod_message_metric));

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
/* need not overflow */
strncpy(mm->metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN);
#pragma GCC diagnostic pop

mm->metric_value_type = metric_value_type;
mm->metric_value_len = metric_value_len;
Expand Down
6 changes: 6 additions & 0 deletions src/cerebrod/cerebrod_speaker_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,11 @@ _get_module_metric_value(unsigned int index)
goto cleanup;
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
/* need not overflow */
strncpy(mm->metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN);
#pragma GCC diagnostic pop

if (metric_module_get_metric_value(metric_handle,
index,
Expand Down Expand Up @@ -538,10 +541,13 @@ _get_userspace_metric_value(struct cerebrod_speaker_metric_info *metric_info)
mm = Malloc(sizeof(struct cerebrod_message_metric));
memset(mm, '\0', sizeof(struct cerebrod_message_metric));

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
/* need not overflow */
strncpy(mm->metric_name,
metric_info->metric_name,
CEREBRO_MAX_METRIC_NAME_LEN);
#pragma GCC diagnostic pop

mm->metric_value_type = metric_info->metric_value_type;
mm->metric_value_len = metric_info->metric_value_len;
Expand Down
3 changes: 3 additions & 0 deletions src/libs/cerebro/cerebro_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ _event_server_request_send(cerebro_t handle,
}

req.version = CEREBRO_EVENT_SERVER_PROTOCOL_VERSION;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(req.event_name, event_name, CEREBRO_MAX_EVENT_NAME_LEN);
#pragma GCC diagnostic pop
req.flags = flags;

if ((req_len = _event_server_request_marshall(handle,
Expand Down
3 changes: 3 additions & 0 deletions src/libs/cerebro/cerebro_metric_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ _metric_control_request_send(cerebro_t handle,
req.version = CEREBRO_METRIC_CONTROL_PROTOCOL_VERSION;
req.command = command;
req.flags = flags;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(req.metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN);
#pragma GCC diagnostic pop
req.metric_value_type = metric_value_type;
req.metric_value_len = metric_value_len;
req.metric_value = metric_value;
Expand Down
3 changes: 3 additions & 0 deletions src/libs/cerebro/cerebro_metric_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ _metric_server_request_send(cerebro_t handle,
}

req.version = CEREBRO_METRIC_SERVER_PROTOCOL_VERSION;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(req.metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN);
#pragma GCC diagnostic pop
req.timeout_len = timeout_len;
req.flags = flags;

Expand Down
4 changes: 4 additions & 0 deletions src/libs/wrappers/wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ void
wrap_free(WRAPPERS_ARGS, void *ptr)
{
void *p = ptr - 2*sizeof(int);
#ifndef NDEBUG
int i, size;
char *c;
#endif

assert(file && function);

Expand All @@ -76,10 +78,12 @@ wrap_free(WRAPPERS_ARGS, void *ptr)
if (!(*((int *)p) == MALLOC_MAGIC))
WRAPPERS_ERR_MSG("free", "memory corruption");

#ifndef NDEBUG
size = *((int *)(p + sizeof(int)));
c = (char *)(p + 2*sizeof(int) + size);
for (i = 0; i < MALLOC_PAD_LEN; i++)
assert(c[i] == (char)MALLOC_PAD_DATA);
#endif
free(p);
}

Expand Down
3 changes: 3 additions & 0 deletions src/modules/event/cerebro_event_updown.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,11 @@ _create_event(const char *nodename, int state)

event->version = CEREBRO_EVENT_PROTOCOL_VERSION;
event->err_code = CEREBRO_EVENT_SERVER_PROTOCOL_ERR_SUCCESS;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(event->nodename, nodename, CEREBRO_MAX_NODENAME_LEN);
strncpy(event->event_name, UPDOWN_EVENT_NAME, CEREBRO_MAX_EVENT_NAME_LEN);
#pragma GCC diagnostic pop
event->event_value_type = CEREBRO_DATA_VALUE_TYPE_INT32;
event->event_value_len = sizeof(int32_t);
if (!(event->event_value = malloc(sizeof(int32_t))))
Expand Down
11 changes: 5 additions & 6 deletions src/modules/metric/cerebro_metric_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ cerebro_metric_get_network(u_int64_t *bytesin,
u_int64_t tx_bytes;
u_int32_t rx_packets, rx_errs;
u_int32_t tx_packets, tx_errs;
u_int32_t temp;
char *strptr;

/* skip the device name */
Expand Down Expand Up @@ -177,31 +176,31 @@ cerebro_metric_get_network(u_int64_t *bytesin,
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
goto cleanup;
}
temp = strtoul(strptr, &strptr, 10); /* drop */
(void)strtoul(strptr, &strptr, 10); /* drop */
if (!strptr)
{
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
goto cleanup;
}
temp = strtoul(strptr, &strptr, 10); /* fifo */
(void)strtoul(strptr, &strptr, 10); /* fifo */
if (!strptr)
{
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
goto cleanup;
}
temp = strtoul(strptr, &strptr, 10); /* frame */
(void)strtoul(strptr, &strptr, 10); /* frame */
if (!strptr)
{
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
goto cleanup;
}
temp = strtoul(strptr, &strptr, 10); /* compressed */
(void)strtoul(strptr, &strptr, 10); /* compressed */
if (!strptr)
{
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
goto cleanup;
}
temp = strtoul(strptr, &strptr, 10); /* multicast */
(void)strtoul(strptr, &strptr, 10); /* multicast */
if (!strptr)
{
CEREBRO_ERR(("%s parse error", NETWORK_FILE));
Expand Down

0 comments on commit 552fde9

Please sign in to comment.