Ntimed icon indicating copy to clipboard operation
Ntimed copied to clipboard

Build problems with default flags on NetBSD

Open 0-wiz-0 opened this issue 10 years ago • 2 comments

When building on NetBSD-7.99.3/amd64 (gcc 4.8.4) with BSD make, I need to add MAN= to the Makefile generated by configure (patch available on request).

Then, the build fails because of the default c compiler flags, with

--- main_sim_client.o ---
main_sim_client.c: In function 'simfile_readline':
main_sim_client.c:138:17: error: conversion to 'unsigned int' from '__uint64_t' may alter its value [-Werror=conversion]
     sf->t0 = u1 - t0.sec;
                 ^
cc1: all warnings being treated as errors
*** [main_sim_client.o] Error code 1

make: stopped in /scratch/wip/ntimed-git/work/Ntimed
--- ntp_packet.o ---
In file included from ntp_packet.c:64:0:
ntimed_endian.h: In function 'Be16dec':
ntimed_endian.h:42:22: error: conversion to '__uint16_t' from 'int' may alter its value [-Werror=conversion]
  return ((p[0] << 8) | p[1]);
                      ^
ntimed_endian.h: In function 'Be32dec':
ntimed_endian.h:50:41: error: conversion to 'unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
  return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
                                         ^
ntimed_endian.h:50:56: error: conversion to 'unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
  return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
                                                        ^
ntimed_endian.h: In function 'Be16enc':
ntimed_endian.h:58:18: error: conversion to '__uint8_t' from 'int' may alter its value [-Werror=conversion]
  p[0] = (u >> 8) & 0xff;
                  ^
ntimed_endian.h:59:11: error: conversion to '__uint8_t' from 'int' may alter its value [-Werror=conversion]
  p[1] = u & 0xff;
           ^
ntimed_endian.h: In function 'Be32enc':
ntimed_endian.h:67:19: error: conversion to '__uint8_t' from '__uint32_t' may alter its value [-Werror=conversion]
  p[0] = (u >> 24) & 0xff;
                   ^
ntp_packet.c: In function 'ts_2ntp32':
ntp_packet.c:139:17: error: conversion to '__uint16_t' from '__uint64_t' may alter its value [-Werror=conversion]
  Be16enc(dst, ts->sec);
                 ^
ntp_packet.c:140:28: error: conversion to '__uint16_t' from '__uint64_t' may alter its value [-Werror=conversion]
  Be16enc(dst + 2, ts->frac >> 48ULL);
                            ^
ntp_packet.c: In function 'ts_2ntp64':
ntp_packet.c:148:23: error: conversion to '__uint32_t' from 'long unsigned int' may alter its value [-Werror=conversion]
  Be32enc(dst, ts->sec + NTP_UNIX);
                       ^
ntp_packet.c:149:28: error: conversion to '__uint32_t' from '__uint64_t' may alter its value [-Werror=conversion]
  Be32enc(dst + 4, ts->frac >> 32ULL);
                            ^
ntp_packet.c: In function 'NTP_Packet_Pack':
ntp_packet.c:163:34: error: conversion to '__uint8_t' from 'int' may alter its value [-Werror=conversion]
  pbuf[0] = (uint8_t)np->ntp_leap << 6;
                                  ^
ntp_packet.c:164:10: error: conversion to '__uint8_t' from 'int' may alter its value [-Werror=conversion]
  pbuf[0] |= np->ntp_version << 3;
          ^
cc1: all warnings being treated as errors
*** [ntp_packet.o] Error code 1

make: stopped in /scratch/wip/ntimed-git/work/Ntimed
--- combine_delta.o ---
combine_delta.c: In function 'cd_find_peak':
combine_delta.c:163:21: error: conversion to 'size_t' from 'long int' may change the sign of the result [-Werror=sign-conversion]
  qsort(st, cd->nsrc * 3L, sizeof st[0], stat_cmp);
                     ^
cc1: all warnings being treated as errors
*** [combine_delta.o] Error code 1

make: stopped in /scratch/wip/ntimed-git/work/Ntimed
--- ntp_peer.o ---
ntp_peer.c:136:17: error: conversion to 'int' from 'ssize_t' may alter its value [-Werror=conversion]
   i = UdpTimedRx(ocx, usc, np->sa->sa_family, &rss, &rssl, &t2,
                 ^
cc1: all warnings being treated as errors
*** [ntp_peer.o] Error code 1

0-wiz-0 avatar Jan 09 '15 11:01 0-wiz-0

Is it WARNS=6 that enables these warnings on NetBSD ?

bsdphk avatar Jan 16 '15 20:01 bsdphk

When I change the WARNS to '5', there are no warnings, so "yes".

0-wiz-0 avatar Jan 16 '15 23:01 0-wiz-0