about summary refs log tree commit diff
path: root/tools/check-nm-autoptr.sh
blob: 466958c89b56a03d3bac4973832020acf326941f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

set -e

die() {
    printf "%s\n" "$*" >&2
    exit 1
}

cd "$(dirname "$(readlink -f "$0")")/.." || die "cannot change to srcdir"

AUTOPTR_H=./src/libnm-client-public/nm-autoptr.h

for s in $( sed -n 's/^ *typedef \+struct \+.*[A-Za-z0-9_]\+ \+\(NMSetting[A-Za-z0-9_]\+\)\> *;$/\1/p' ./src/libnm-core-public/nm-core-types.h ) ; do
    grep -q "^ *G_DEFINE_AUTOPTR_CLEANUP_FUNC *( *\\<$s\\> *, *g_object_unref *)" -- "$AUTOPTR_H" || die "didn't see setting '$s' in \"$AUTOPTR_H\""
done

for s in $( grep -h -o '\<NMDevice[A-Za-z0-9_]\+\>' ./src/libnm-client-public/nm-device-*.h | sort -u | grep -v 'Class$') ; do
    case "$s" in
        NMDeviceModemCapabilities| \
        NMDeviceWifiCapabilities)
            continue
            ;;
    esac
    grep -q "^ *G_DEFINE_AUTOPTR_CLEANUP_FUNC *( *\\<$s\\> *, *g_object_unref *)" -- "$AUTOPTR_H" || die "didn't see device '$s' in \"$AUTOPTR_H\""
done