Bug 258376 - net/libnfs: including libnfs.h can cause compile error (missing struct timeval)
Summary: net/libnfs: including libnfs.h can cause compile error (missing struct timeval)
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-08 21:07 UTC by John Hein
Modified: 2021-09-09 17:30 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (snoe925)


Attachments
[patch] include sys/time.h instead of time.h in libnfs.h (814 bytes, patch)
2021-09-08 21:17 UTC, John Hein
jcfyecrayz: maintainer-approval? (snoe925)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2021-09-08 21:07:28 UTC
Building code that includes libnfs.h can trigger a build error...

Simple test case:

% cat test-libnfs.h.c 
#include <nfsc/libnfs.h>
% cc -I/usr/local/include -c -o /dev/null test-libnfs.h.c
In file included from test-libnfs.h.c:1:
/usr/local/include/nfsc/libnfs.h:1216:23: error: field has incomplete type 'struct timeval'
       struct timeval atime;
                      ^
/usr/local/include/nfsc/libnfs.h:1216:15: note: forward declaration of 'struct timeval'
       struct timeval atime;
              ^
/usr/local/include/nfsc/libnfs.h:1217:23: error: field has incomplete type 'struct timeval'
       struct timeval mtime;
                      ^
/usr/local/include/nfsc/libnfs.h:1216:15: note: forward declaration of 'struct timeval'
       struct timeval atime;
              ^
/usr/local/include/nfsc/libnfs.h:1218:23: error: field has incomplete type 'struct timeval'
       struct timeval ctime;
                      ^
/usr/local/include/nfsc/libnfs.h:1216:15: note: forward declaration of 'struct timeval'
       struct timeval atime;
              ^
3 errors generated.
Comment 1 John Hein 2021-09-08 21:12:38 UTC
See also bug 258349 for a real world example.
Comment 2 John Hein 2021-09-08 21:17:06 UTC
Created attachment 227772 [details]
[patch] include sys/time.h instead of time.h in libnfs.h

Include sys/time.h instead of time.h in libnfs.h

Can be submitted upstream.  Better might be for libnfs to detect the right time.h to include based on a 'configure' test rather than hard-coding OS dependent ifdefs.
Comment 3 John Hein 2021-09-08 21:23:00 UTC
(In reply to John Hein from comment #2)
Patch was QA tested with:
 - poudriere testport (11-stable, 12-stable) - ok
 - portlint (no new errors or warnings, but there are existing portlint errors [1] that could be fixed in addition to this patch)

[1]

% portlint
FATAL: Makefile: DISTVERSIONPREFIX appears out-of-order.
FATAL: Makefile: order must be PORTNAME/PORTVERSION/DISTVERSIONPREFIX/DISTVERSION/DISTVERSIONSUFFIX/PORTREVISION/PORTEPOCH/CATEGORIES/MASTER_SITES/MASTER_SITE_SUBDIR/PROJECTHOST/PKGNAMEPREFIX/PKGNAMESUFFIX/DISTNAME/EXTRACT_SUFX/DISTFILES(_\w+)?/DIST_SUBDIR/EXTRACT_ONLY.
WARN: Makefile: "USES" has to appear earlier.
2 fatal errors and 1 warning found.
Comment 4 John Hein 2021-09-09 02:39:59 UTC
Upstream bug also filed: https://github.com/sahlberg/libnfs/issues/358