Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2017 11:50:13 +0200
From:      Robin Seggelmann <robin@seggelmann.com>
To:        gnome@FreeBSD.org
Subject:   FreeBSD Port: sysutils/consolekit2
Message-ID:  <2BC8D4DC-A655-4317-839D-86B6CC3B0EF2@seggelmann.com>

next in thread | raw e-mail | index | archive | help
Hi,

I=E2=80=99m trying to build consolekit2 as a dependency for xfce4 on =
FreeBSD 10.3 on a PowerPC G4, but came across two compilation errors =
I=E2=80=99d like to report:


ck-sysdeps-unix.c: In function 'ck_get_socket_peer_credentials':
ck-sysdeps-unix.c:176: error: 'for' loop initial declaration used =
outside C99 mode
gmake[5]: *** [Makefile:1276: ck-sysdeps-unix.lo] Error 1


The section of the corresponding file looks like that:


#ifdef __FreeBSD__
        kd =3D kvm_openfiles (NULL, _PATH_DEVNULL, NULL, O_RDONLY, =
errbuf);
        if (kd =3D=3D NULL) {
                g_warning ("kvm_openfiles failed: %s", errbuf);
                return FALSE;
        }
=20
        prc =3D kvm_getprocs (kd, KERN_PROC_UID, uid_read, &cnt);
        for (int i =3D 0; i < cnt; i++) {
                if(strncmp (prc[i].ki_comm, "Xorg", 4) =3D=3D 0) {
                        pid_read =3D prc[i].ki_pid;
                        break;
                }
        }
=20
        kvm_close(kd);
#endif /* __FreeBSD__ */


This can be fixed with the following patch:


--- work/ConsoleKit2-1.2.0/src/ck-sysdeps-unix.c.orig	2017-08-18 =
11:32:04.192493000 +0200
+++ work/ConsoleKit2-1.2.0/src/ck-sysdeps-unix.c	2017-08-18 =
11:32:24.414818000 +0200
@@ -173,7 +173,8 @@
         }
=20
         prc =3D kvm_getprocs (kd, KERN_PROC_UID, uid_read, &cnt);
-        for (int i =3D 0; i < cnt; i++) {
+        int i;       =20
+        for (i =3D 0; i < cnt; i++) {
                 if(strncmp (prc[i].ki_comm, "Xorg", 4) =3D=3D 0) {
                         pid_read =3D prc[i].ki_pid;
                         break;


After this fix the next error shows up, basically the same issue:


ck-get-x11-display-device.c: In function 'get_tty_for_pid':
ck-get-x11-display-device.c:87: error: 'for' loop initial declaration =
used outside C99 mode
gmake[4]: *** [Makefile:996: ck-get-x11-display-device.o] Error 1


The part of the corresponding file:


#ifdef __FreeBSD__
#include <libprocstat.h>


static char *
get_tty_for_pid (int pid)
{
        gchar *device =3D NULL;
        gboolean res;
        char errstr[_POSIX2_LINE_MAX];
        int cnt =3D 0;
        struct vnstat vn;
        struct filestat_list *head;
        struct filestat *fst;
        kvm_t* kd;
        struct kinfo_proc * prc;
        struct procstat *procstat;

        kd =3D kvm_openfiles (NULL, "/dev/null", NULL, O_RDONLY, =
errstr);
        prc =3D kvm_getprocs (kd, KERN_PROC_PID, pid, &cnt);
        procstat =3D procstat_open_sysctl ();

        for (int i =3D 0; i < cnt; i++) {
                head =3D procstat_getfiles (procstat,&prc[i], 0);

                STAILQ_FOREACH (fst, head, next) {
                        if (fst->fs_type =3D=3D PS_FST_TYPE_VNODE) {
                                procstat_get_vnode_info (procstat, fst, =
&vn, NULL);

                                if (vn.vn_type =3D=3D PS_FST_VTYPE_VCHR) =
{
                                        char *ctty =3D devname( =
prc[i].ki_tdev,S_IFCHR);
                                        const char * pre =3D "ttyv";

                                        if(strncmp (pre, vn.vn_devname, =
strlen (pre)) =3D=3D 0 && strncmp (vn.vn_devname, ctty, strlen(ctty)) !=3D=
 0) {
                                                device =3D =
g_strdup_printf ("/dev/%s", vn.vn_devname);
                                                procstat_freefiles =
(procstat, head);
                                                res =3D TRUE;
                                                return device;
                                        }
                                }
                        }
                }
        }

        procstat_freefiles(procstat, head);
        return device;
}
#else /* __FreeBSD__ */


The patch for this is also similar:


--- work/ConsoleKit2-1.2.0/tools/ck-get-x11-display-device.c.orig	=
2017-08-18 11:42:01.953620000 +0200
+++ work/ConsoleKit2-1.2.0/tools/ck-get-x11-display-device.c	=
2017-08-18 11:42:21.864176000 +0200
@@ -84,7 +84,8 @@
         prc =3D kvm_getprocs (kd, KERN_PROC_PID, pid, &cnt);
         procstat =3D procstat_open_sysctl ();
=20
-        for (int i =3D 0; i < cnt; i++) {
+        int i;
+        for (i =3D 0; i < cnt; i++) {
                 head =3D procstat_getfiles (procstat,&prc[i], 0);
=20
                 STAILQ_FOREACH (fst, head, next) {


After that the build is successful and the package installs. I have also =
attached the entire build output.

Best regards,
Robin







Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2BC8D4DC-A655-4317-839D-86B6CC3B0EF2>