Bug 258376

Summary: net/libnfs: including libnfs.h can cause compile error (missing struct timeval)
Product: Ports & Packages Reporter: John Hein <jcfyecrayz>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: krion, snoe925, vvd
Priority: --- Flags: bugzilla: maintainer-feedback? (snoe925)
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258349
Attachments:
Description Flags
[patch] include sys/time.h instead of time.h in libnfs.h
jcfyecrayz: maintainer-approval? (snoe925)
Update to 5.0.1 vvd: maintainer-approval?

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
Comment 5 Vladimir Druzenko freebsd_committer freebsd_triage 2022-04-16 12:38:15 UTC
Created attachment 233249 [details]
Update to 5.0.1

With sys/time.h fixed and order in Makefile.

P.S. Is it maintainer timeout?
Comment 6 Kirill Ponomarev freebsd_committer freebsd_triage 2022-04-17 07:03:39 UTC
Fix committed, don't forget to send PR to upstream, it seems it's not done yet.
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2022-04-17 11:31:00 UTC
(In reply to Kirill Ponomarev from comment #6)
> Fix committed,
Thanks!

> don't forget to send PR to upstream, it seems it's not done yet.
Already yesterday: https://github.com/sahlberg/libnfs/issues/358#issuecomment-1100646146
Comment 8 Vladimir Druzenko freebsd_committer freebsd_triage 2022-05-19 14:11:25 UTC
Commited in upstream:
https://github.com/sahlberg/libnfs/commit/cc916b8b9f389d45063cd280f52bd202b4a847c8
Waiting new release.