fix a number of warnings and errors for clang

This commit is contained in:
naddy 2017-05-08 21:40:10 +00:00
parent 20ebd9a874
commit f3d429c259
10 changed files with 167 additions and 2 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.26 2017/04/10 11:46:32 sthen Exp $
# $OpenBSD: Makefile,v 1.27 2017/05/08 21:40:10 naddy Exp $
COMMENT= Sandia Internet path characterization tool
DISTNAME= pchar-1.5
REVISION= 0
CATEGORIES= net
MASTER_SITES= ${HOMEPAGE}
@ -17,9 +18,11 @@ CONFIGURE_ARGS= --with-ipv6 --with-pcap
NO_TEST= Yes
post-patch:
/usr/bin/perl -pi.beforesubst -e 's/pchar 1/pchar 8/g' ${WRKSRC}/pchar.8
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/pchar ${PREFIX}/sbin
@/usr/bin/perl -pi.orig -e 's/pchar 1/pchar 8/g' ${WRKSRC}/pchar.8
${INSTALL_MAN} ${WRKSRC}/pchar.8 ${PREFIX}/man/man8/pchar.8
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/pchar
cd ${WRKSRC} ; ${INSTALL_DATA} README FAQ ${PREFIX}/share/doc/pchar

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-PctestIpv4File_cc,v 1.3 2017/05/08 21:40:10 naddy Exp $
Index: PctestIpv4File.cc
--- PctestIpv4File.cc.orig
+++ PctestIpv4File.cc
@@ -84,6 +84,8 @@ int PctestIpv4File::SetOriginName(char *t) {
fprintf(stderr, "Couldn't allocate memory for origin hostname.\n");
return -1;
}
+
+ return 0;
}
//

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-PctestIpv4_h,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: PctestIpv4.h
--- PctestIpv4.h.orig
+++ PctestIpv4.h
@@ -77,7 +77,7 @@ class PctestIpv4 : public Pctest {
virtual char *GetPrintableAddress();
virtual char *GetPrintableAddress(void *a);
virtual char *GetName(void *a);
- virtual char *GetAddressFamilyString() { return "AF_INET"; };
+ virtual const char *GetAddressFamilyString() { return "AF_INET"; };
virtual int GetAddressFamily() { return (AF_INET); };
protected:

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-PctestIpv6File_cc,v 1.3 2017/05/08 21:40:10 naddy Exp $
Index: PctestIpv6File.cc
--- PctestIpv6File.cc.orig
+++ PctestIpv6File.cc
@@ -101,6 +101,8 @@ int PctestIpv6File::SetOriginName(char *t) {
fprintf(stderr, "Couldn't allocate memory for origin hostname.\n");
return -1;
}
+
+ return 0;
}
//

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-PctestIpv6_h,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: PctestIpv6.h
--- PctestIpv6.h.orig
+++ PctestIpv6.h
@@ -82,7 +82,7 @@ class PctestIpv6 : public Pctest {
virtual char *GetPrintableAddress();
virtual char *GetPrintableAddress(void *a);
virtual char *GetName(void *a);
- virtual char *GetAddressFamilyString() { return "AF_INET6"; }
+ virtual const char *GetAddressFamilyString() { return "AF_INET6"; }
virtual int GetAddressFamily() { return (AF_INET6); }
protected:

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-Pctest_h,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: Pctest.h
--- Pctest.h.orig
+++ Pctest.h
@@ -86,7 +86,7 @@ class Pctest {
virtual char *GetPrintableAddress() = 0;
virtual char *GetPrintableAddress(void *a) = 0;
virtual char *GetName(void *a) = 0;
- virtual char *GetAddressFamilyString() = 0;
+ virtual const char *GetAddressFamilyString() = 0;
virtual int GetAddressFamily() = 0;
// Get input and output sockets needed

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-ResultTable_cc,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: ResultTable.cc
--- ResultTable.cc.orig
+++ ResultTable.cc
@@ -44,7 +44,7 @@ ResultTable::ResultTable(unsigned int inc, unsigned in
// can't handle "new (footype *)[bar]". We're trying to do:
// data = new (double *) [columns];
typedef double *DoublePtr;
- data = new (double *[columns]);
+ data = new DoublePtr[columns];
if (data == NULL) {
fprintf(stderr, "Couldn't allocate data array for a ResultTable\n");
exit(1);
@@ -909,7 +909,7 @@ void ResultTable::lmsint(double &a, double &b, double
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- residuals[l] = abs(partialmins[i] -
+ residuals[l] = abs((long)partialmins[i] -
((currentslope *
column2size(i) /
slopescale) +
@@ -930,7 +930,7 @@ void ResultTable::lmsint(double &a, double &b, double
l = 0;
for (i = 0; i < columns; i++) {
if (partialmins[i] != timeoutresult) {
- ys[l] = abs(partialmins[i] - mediany);
+ ys[l] = abs((long)partialmins[i] - mediany);
l++;
}
}

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-TestRecord_cc,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: TestRecord.cc
--- TestRecord.cc.orig
+++ TestRecord.cc
@@ -53,7 +53,7 @@ char *TestRecord::htoa(Pctest *pct)
#else
sprintf(buffer2,
#endif /* HAVE_SNPRINTF */
- "probe t %ld.%06ld ", tvstart.tv_sec, tvstart.tv_usec);
+ "probe t %lld.%06ld ", (long long)tvstart.tv_sec, (long)tvstart.tv_usec);
strncat(buffer, buffer2, buflen);
#ifdef HAVE_SNPRINTF
@@ -61,7 +61,7 @@ char *TestRecord::htoa(Pctest *pct)
#else
sprintf(buffer2,
#endif /* HAVE_SNPRINTF */
- "h %d b %d addr %s res %d rtt %ld.%06ld rb %d", hops, size, pct->GetPrintableAddress(icmpSourceAddress), result, tv.tv_sec, tv.tv_usec, replsize);
+ "h %d b %d addr %s res %d rtt %lld.%06ld rb %d", hops, size, pct->GetPrintableAddress(icmpSourceAddress), result, (long long)tv.tv_sec, (long)tv.tv_usec, replsize);
strncat(buffer, buffer2, buflen);
return buffer;

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-configure,v 1.1 2017/05/08 21:40:10 naddy Exp $
Index: configure
--- configure.orig
+++ configure
@@ -962,7 +962,7 @@ else
extern "C" void exit(int);
#endif
#include <stdio.h>
-main()
+int main()
{
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);

View File

@ -0,0 +1,23 @@
$OpenBSD: patch-main_cc,v 1.3 2017/05/08 21:40:10 naddy Exp $
Index: main.cc
--- main.cc.orig
+++ main.cc
@@ -292,7 +292,7 @@ char *GetAddressFamily()
//
// Output: ASCII representation of network protocol name.
//
-char *GetPrintableNetworkProtocol(NetworkProtocolType np)
+const char *GetPrintableNetworkProtocol(NetworkProtocolType np)
{
switch (np) {
case (NetworkProtocolIpv4Udp):
@@ -371,7 +371,7 @@ int main(int argc, char **argv)
case 'b': {
Burst = atoi(optarg);
if (Burst < 1) {
- fprintf(stderr, "Warning: burst size %d too small; resetting to 1\n");
+ fprintf(stderr, "Warning: burst size %d too small; resetting to 1\n", Burst);
Burst = 1;
}
break;