Commit Diff


commit - 024cbc79bf3a72da2a3e3d6259a11f57bbe5049d
commit + b3113ed03f94f509640ec7076d4c6284bb5a15a2
blob - 335a33c3cbd0861e8241810c8ee083f61e6e8e36
blob + c97b2578b64223001366f5060248df3d81f360c1
--- helpers.c
+++ helpers.c
@@ -30,8 +30,8 @@
 
 typedef struct Fstype_s
 {
-	long type;
-	char *name;
+    long type;
+    char *name;
 } Fstype_s;
 
 // FIXME: more in http://man7.org/linux/man-pages/man2/statfs.2.html
@@ -41,258 +41,244 @@ typedef struct Fstype_s
 	}
 
 Fstype_s Fstype[] = {
-	FSTYPE(ADFS_SUPER_MAGIC),
-	FSTYPE(AFFS_SUPER_MAGIC),
-	FSTYPE(AFS_SUPER_MAGIC),
-	FSTYPE(AUTOFS_SUPER_MAGIC),
-	FSTYPE(CODA_SUPER_MAGIC),
-	FSTYPE(CRAMFS_MAGIC),
-	FSTYPE(CRAMFS_MAGIC_WEND),
-	FSTYPE(DEBUGFS_MAGIC),
-	FSTYPE(SYSFS_MAGIC),
-	FSTYPE(SECURITYFS_MAGIC),
-	FSTYPE(SELINUX_MAGIC),
-	FSTYPE(RAMFS_MAGIC),
-	FSTYPE(TMPFS_MAGIC),
-	FSTYPE(HUGETLBFS_MAGIC),
-	FSTYPE(SQUASHFS_MAGIC),
-	FSTYPE(EFS_SUPER_MAGIC),
-	FSTYPE(EXT2_SUPER_MAGIC),
-	FSTYPE(EXT3_SUPER_MAGIC),
-	FSTYPE(XENFS_SUPER_MAGIC),
-	FSTYPE(EXT4_SUPER_MAGIC),
-	FSTYPE(BTRFS_SUPER_MAGIC),
-	FSTYPE(HPFS_SUPER_MAGIC),
-	FSTYPE(ISOFS_SUPER_MAGIC),
-	FSTYPE(JFFS2_SUPER_MAGIC),
-	FSTYPE(ANON_INODE_FS_MAGIC),
-	FSTYPE(MINIX_SUPER_MAGIC),
-	FSTYPE(MINIX_SUPER_MAGIC2),
-	FSTYPE(MINIX2_SUPER_MAGIC),
-	FSTYPE(MINIX2_SUPER_MAGIC2),
-	FSTYPE(MINIX3_SUPER_MAGIC),
-	FSTYPE(MSDOS_SUPER_MAGIC),
-	FSTYPE(NCP_SUPER_MAGIC),
-	FSTYPE(NFS_SUPER_MAGIC),
-	FSTYPE(OPENPROM_SUPER_MAGIC),
-	FSTYPE(PROC_SUPER_MAGIC),
-	FSTYPE(QNX4_SUPER_MAGIC),
-	FSTYPE(REISERFS_SUPER_MAGIC),
-	FSTYPE(SMB_SUPER_MAGIC),
-	FSTYPE(USBDEVICE_SUPER_MAGIC),
-	FSTYPE(CGROUP_SUPER_MAGIC),
-	FSTYPE(FUTEXFS_SUPER_MAGIC),
-	/*FSTYPE(INOTIFYFS_SUPER_MAGIC), not defined in earlier headers */
-	FSTYPE(STACK_END_MAGIC),
-	FSTYPE(DEVPTS_SUPER_MAGIC),
-	FSTYPE(SOCKFS_MAGIC)
+    FSTYPE(ADFS_SUPER_MAGIC),
+    FSTYPE(AFFS_SUPER_MAGIC),
+    FSTYPE(AFS_SUPER_MAGIC),
+    FSTYPE(AUTOFS_SUPER_MAGIC),
+    FSTYPE(CODA_SUPER_MAGIC),
+    FSTYPE(CRAMFS_MAGIC),
+    FSTYPE(CRAMFS_MAGIC_WEND),
+    FSTYPE(DEBUGFS_MAGIC),
+    FSTYPE(SYSFS_MAGIC),
+    FSTYPE(SECURITYFS_MAGIC),
+    FSTYPE(SELINUX_MAGIC),
+    FSTYPE(RAMFS_MAGIC),
+    FSTYPE(TMPFS_MAGIC),
+    FSTYPE(HUGETLBFS_MAGIC),
+    FSTYPE(SQUASHFS_MAGIC),
+    FSTYPE(EFS_SUPER_MAGIC),
+    FSTYPE(EXT2_SUPER_MAGIC),
+    FSTYPE(EXT3_SUPER_MAGIC),
+    FSTYPE(XENFS_SUPER_MAGIC),
+    FSTYPE(EXT4_SUPER_MAGIC),
+    FSTYPE(BTRFS_SUPER_MAGIC),
+    FSTYPE(HPFS_SUPER_MAGIC),
+    FSTYPE(ISOFS_SUPER_MAGIC),
+    FSTYPE(JFFS2_SUPER_MAGIC),
+    FSTYPE(ANON_INODE_FS_MAGIC),
+    FSTYPE(MINIX_SUPER_MAGIC),
+    FSTYPE(MINIX_SUPER_MAGIC2),
+    FSTYPE(MINIX2_SUPER_MAGIC),
+    FSTYPE(MINIX2_SUPER_MAGIC2),
+    FSTYPE(MINIX3_SUPER_MAGIC),
+    FSTYPE(MSDOS_SUPER_MAGIC),
+    FSTYPE(NCP_SUPER_MAGIC),
+    FSTYPE(NFS_SUPER_MAGIC),
+    FSTYPE(OPENPROM_SUPER_MAGIC),
+    FSTYPE(PROC_SUPER_MAGIC),
+    FSTYPE(QNX4_SUPER_MAGIC),
+    FSTYPE(REISERFS_SUPER_MAGIC),
+    FSTYPE(SMB_SUPER_MAGIC),
+    FSTYPE(USBDEVICE_SUPER_MAGIC),
+    FSTYPE(CGROUP_SUPER_MAGIC),
+    FSTYPE(FUTEXFS_SUPER_MAGIC),
+    /*FSTYPE(INOTIFYFS_SUPER_MAGIC), not defined in earlier headers */
+    FSTYPE(STACK_END_MAGIC),
+    FSTYPE(DEVPTS_SUPER_MAGIC),
+    FSTYPE(SOCKFS_MAGIC)
 };
-
 #endif
 
 osinfo *get_os_info(void)
 {
-	osinfo *os = (osinfo *)malloc(sizeof (osinfo));
+    osinfo *os = (osinfo *)malloc(sizeof (osinfo));
 #if WIN32
-	os.os_version = NULL;
-	os.os_name = NULL;
-	os.os_family = NULL;
-	os.arch = NULL;
+    os.os_version = NULL;
+    os.os_name = NULL;
+    os.os_family = NULL;
+    os.arch = NULL;
 #else
-	struct utsname u;
-	if (uname(&u) == -1)
-		err(1, NULL);
-	os->os_version = (char *)malloc(256);
-	strcpy(os->os_version, u.version);
-	os->os_name = (char *)malloc(256);
-	strcpy(os->os_name, u.release);
-	os->os_family = (char *)malloc(256);
-	strcpy(os->os_family, u.sysname);
-	os->os_arch = (char *)malloc(256);
-	strcpy(os->os_arch, u.machine);
+    struct utsname u;
+    if (uname(&u) == -1) {
+        err(1, NULL);
+    }
+    os->os_version = (char *)malloc(256);
+    strcpy(os->os_version, u.version);
+    os->os_name = (char *)malloc(256);
+    strcpy(os->os_name, u.release);
+    os->os_family = (char *)malloc(256);
+    strcpy(os->os_family, u.sysname);
+    os->os_arch = (char *)malloc(256);
+    strcpy(os->os_arch, u.machine);
 #endif
-
-	return os;
-
-	/*
-	     16.x.x  macOS 10.12.x Sierra
-	     15.x.x  OS X  10.11.x El Capitan
-	     14.x.x  OS X  10.10.x Yosemite
-	     13.x.x  OS X  10.9.x  Mavericks
-	     12.x.x  OS X  10.8.x  Mountain Lion
-	     11.x.x  OS X  10.7.x  Lion
-	     10.x.x  OS X  10.6.x  Snow Leopard
-	      9.x.x  OS X  10.5.x  Leopard
-	      8.x.x  OS X  10.4.x  Tiger
-	      7.x.x  OS X  10.3.x  Panther
-	      6.x.x  OS X  10.2.x  Jaguar
-	      5.x    OS X  10.1.x  Puma
-	     */
+    return os;
 }
 
 hwinfo *get_hw_info(void)
 {
-	hwinfo *hw = (hwinfo *)malloc(sizeof (hwinfo));
+    hwinfo *hw = (hwinfo *)malloc(sizeof (hwinfo));
 #ifdef __APPLE__
-	uint32_t count;
-	int64_t physmem;
-	size_t siz;
-	int mib[2];
-	struct timeval ts;
+    uint32_t count;
+    int64_t physmem;
+    size_t siz;
+    int mib[2];
+    struct timeval ts;
 
-	siz = sizeof (count);
-	mib[0] = CTL_HW;
-	mib[1] = HW_AVAILCPU;
-	sysctl(mib, 2, &count, &siz, NULL, 0);
-	if (count < 1) {
-		mib[1] = HW_NCPU;
-		sysctl(mib, 2, &count, &siz, NULL, 0);
-		if (count < 1) {
-			count = 1;
-		}
-	}
-	hw->ncpu = count;
+    siz = sizeof (count);
+    mib[0] = CTL_HW;
+    mib[1] = HW_AVAILCPU;
+    sysctl(mib, 2, &count, &siz, NULL, 0);
+    if (count < 1) {
+        mib[1] = HW_NCPU;
+        sysctl(mib, 2, &count, &siz, NULL, 0);
+        if (count < 1) {
+            count = 1;
+        }
+    }
+    hw->ncpu = count;
 
-	mib[0] = CTL_HW;
-	mib[1] = HW_MEMSIZE;
-	siz = sizeof (int64_t);
-	if (sysctl(mib, 2, &physmem, &siz, NULL, 0) == -1)
-		err(1, "sysctl");
-	hw->memsize = physmem;
+    mib[0] = CTL_HW;
+    mib[1] = HW_MEMSIZE;
+    siz = sizeof (int64_t);
+    if (sysctl(mib, 2, &physmem, &siz, NULL, 0) == -1) {
+        err(1, "sysctl");
+    }
+    hw->memsize = physmem;
 
-	siz = sizeof (ts);
-	mib[0] = CTL_KERN;
-	mib[1] = KERN_BOOTTIME;
-	if (sysctl(mib, 2, &ts, &siz, NULL, 0) != 0)
-		err(1, "sysctl");
-	time_t bsec = ts.tv_sec, csec = time(NULL);
-	hw->uptime = difftime(csec, bsec);
+    siz = sizeof (ts);
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_BOOTTIME;
+    if (sysctl(mib, 2, &ts, &siz, NULL, 0) != 0) {
+        err(1, "sysctl");
+    }
+    time_t bsec = ts.tv_sec, csec = time(NULL);
+    hw->uptime = difftime(csec, bsec);
 #elif __OpenBSD__ || __FreeBSD__ || __NetBSD__
-	uint32_t count;
-	int64_t physmem;
-	size_t siz;
-	int mib[2];
-	struct timeval ts;
-	time_t bsec, csec;
+    uint32_t count;
+    int64_t physmem;
+    size_t siz;
+    int mib[2];
+    struct timeval ts;
+    time_t bsec, csec;
 
-	mib[0] = CTL_HW;
-	mib[1] = HW_NCPUFOUND;
-	siz = sizeof (count);
-	if (sysctl(mib, 2, &count, &siz, NULL, 0) == -1)
-		err(1, "sysctl");
+    mib[0] = CTL_HW;
+    mib[1] = HW_NCPUFOUND;
+    siz = sizeof (count);
+    if (sysctl(mib, 2, &count, &siz, NULL, 0) == -1) {
+        err(1, "sysctl");
+    }
 
-	mib[0] = CTL_HW;
-	mib[1] = HW_PHYSMEM64;
-	if (sysctl(mib, 2, &physmem, &siz, NULL, 0) < 0) {
-		warnx("physmem: failed to get hw.physmem");
-	}
+    mib[0] = CTL_HW;
+    mib[1] = HW_PHYSMEM64;
+    if (sysctl(mib, 2, &physmem, &siz, NULL, 0) < 0) {
+        warnx("physmem: failed to get hw.physmem");
+    }
 
-	siz = sizeof (ts);
-	mib[0] = CTL_KERN;
-	mib[1] = KERN_BOOTTIME;
-	if (sysctl(mib, 2, &ts, &siz, NULL, 0) != 0)
-		err(1, "sysctl");
-	bsec = ts.tv_sec;
-	csec = time(NULL);
-	hw->uptime = difftime(csec, bsec);
+    siz = sizeof (ts);
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_BOOTTIME;
+    if (sysctl(mib, 2, &ts, &siz, NULL, 0) != 0) {
+        err(1, "sysctl");
+    }
+    bsec = ts.tv_sec;
+    csec = time(NULL);
+    hw->uptime = difftime(csec, bsec);
 #elif __linux__
-	struct sysinfo sys_info;
-	int32_t total_ram = 0;
-	if (sysinfo(&sys_info) != 0)
-		err(1, "sysinfo");
-	total_ram = ((uint64_t)sys_info.totalram * sys_info.mem_unit) / 1024;
-	hw->ncpu = sysconf(_SC_NPROCESSORS_ONLN);
-	hw->memsize = sys_info.uptime;
-	hw->uptime = total_ram;
+    struct sysinfo sys_info;
+    int32_t total_ram = 0;
+    if (sysinfo(&sys_info) != 0) {
+        err(1, "sysinfo");
+    }
+    total_ram = ((uint64_t)sys_info.totalram * sys_info.mem_unit) / 1024;
+    hw->ncpu = sysconf(_SC_NPROCESSORS_ONLN);
+    hw->memsize = sys_info.uptime;
+    hw->uptime = total_ram;
 #elif WIN32
-	SYSTEM_INFO sysinfo;
-	GetSystemInfo(&sysinfo);
-	hw->ncpu = sysinfo.dwNumberOfProcessors;
-	hw->memsize = NULL; // FIXME
-	hw->uptime = NULL; // FIXME
+    SYSTEM_INFO sysinfo;
+    GetSystemInfo(&sysinfo);
+    hw->ncpu = sysinfo.dwNumberOfProcessors;
+    hw->memsize = NULL; // FIXME
+    hw->uptime = NULL; // FIXME
 #else
-	hw->ncpu = NULL;
-	hw->memsize = NULL;
-	hw->uptime = NULL;
+    hw->ncpu = NULL;
+    hw->memsize = NULL;
+    hw->uptime = NULL;
 #endif
-
-	return hw;
+    return hw;
 }
 
 long long int get_proc_uptime(pid_t pid)
 {
-	unsigned long long proc_uptime;
+    unsigned long long proc_uptime;
 #ifdef __linux__
-	/*
-	       see proc(5) -> /proc/[pid]/stat
-	 */
+    /*
+           see proc(5) -> /proc/[pid]/stat
+     */
 
-	char filename[256];
-	FILE *f;
+    char filename[256];
+    FILE *f;
 
-	sprintf(filename, "/proc/%u/stat", (unsigned)pid);
-	if (-1 == access(filename, R_OK)) {
-		return -1;
-	}
+    sprintf(filename, "/proc/%u/stat", (unsigned)pid);
+    if (-1 == access(filename, R_OK)) {
+            return -1;
+    }
 
-	if ((f = fopen(filename, "r")) == NULL) {
-		return -1;
-	}
+    if ((f = fopen(filename, "r")) == NULL) {
+            return -1;
+    }
 
-	if (fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u"
-	    "%*u %*d %*d %*d %*d %*d %*d %*d %llu %*u %*d",
-	    &proc_uptime)
-	    == EOF) {
-		fclose(f);
-		return -1;
-	}
+    if (fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u"
+        "%*u %*d %*d %*d %*d %*d %*d %*d %llu %*u %*d",
+        &proc_uptime) == EOF) {
+        fclose(f);
+        return -1;
+    }
 
-	fclose(f);
+    fclose(f);
 #elif __APPLE_ || __OpenBSD__ || __FreeBSD__ || __NetBSD__
-	struct kinfo_proc proc;
-	size_t siz = sizeof (proc);
-	const u_int len_path = 4;
-	int ret;
-	int path[len_path];
+    struct kinfo_proc proc;
+    size_t siz = sizeof (proc);
+    const u_int len_path = 4;
+    int ret;
+    int path[len_path];
 
-	path[0] = CTL_KERN;
-	path[1] = KERN_PROC;
-	path[2] = KERN_PROC_PID;
-	path[3] = pid;
-	ret = sysctl(path, len_path, &proc, &siz, NULL, 0);
+    path[0] = CTL_KERN;
+    path[1] = KERN_PROC;
+    path[2] = KERN_PROC_PID;
+    path[3] = pid;
+    ret = sysctl(path, len_path, &proc, &siz, NULL, 0);
 
-	proc_uptime = 0;
+    proc_uptime = 0;
 #else
-	proc_uptime = 0;
+    proc_uptime = 0;
 #endif
-	return proc_uptime;
+    return proc_uptime;
 }
 
 #ifdef __linux__
 char *lookup_fstype(long fstype)
 {
-	int i;
-	for (i = 0; i < num_elements(Fstype); i++) {
-		if (fstype == Fstype[i].type)
-			return Fstype[i].name;
-	}
+    int i;
+    for (i = 0; i < num_elements(Fstype); i++) {
+        if (fstype == Fstype[i].type)
+            return Fstype[i].name;
+    }
 
-	return "<fs type unknown>";
+    return "<fs type unknown>";
 }
 #endif
 
 char *dirfs(char *path)
 {
-	struct statfs st;
-	char *fs;
-
-	fs = "";
-	if (statfs(path, &st) == -1)
-		err(1, NULL);
+    struct statfs st;
+    char *fs = "";
+    if (statfs(path, &st) == -1) {
+        err(1, NULL);
+    }
 #ifdef __linux__
-	fs = lookup_fstype(st.f_type);
+    fs = lookup_fstype(st.f_type);
 #elif __APPLE__
-	fs = st.f_fstypename;
+    fs = st.f_fstypename;
 #endif
-	return fs;
+    return fs;
 }
blob - 3fa503ee9f36e7dcc6c550b293e1dcb6c8786169
blob + 4bc4f7c6b1fcea57f8d71a810fe904027fe4e5dd
--- pg_feedback.c
+++ pg_feedback.c
@@ -2,7 +2,7 @@
  *
  * pg_feedback.c
  *
- * Copyright (c) 2017-2019, Sergey Bronnikov
+ * Copyright (c) 2017-2021, Sergey Bronnikov
  *
  *-------------------------------------------------------------------------
  */
@@ -25,21 +25,21 @@
 
 static char *system_db_id()
 {
-	ControlFileData *ControlFile = NULL;
-	char *sysident_str = NULL;
-	sysident_str = (char *)malloc(32);
-	if (!sysident_str) {
-            perror("malloc");
-            return NULL;
-	}
+    ControlFileData *ControlFile = NULL;
+    char *sysident_str = NULL;
+    sysident_str = (char *)malloc(32);
+    if (!sysident_str) {
+        perror("malloc");
+        return NULL;
+    }
 
-	ControlFile = get_controlfile(DataDir, NULL);
-        if (!ControlFile)
-            ereport(ERROR,
-              (errmsg("calculated CRC checksum does not match value stored in file")));
-	snprintf(sysident_str, sizeof (sysident_str), UINT64_FORMAT, ControlFile->system_identifier);
+    ControlFile = get_controlfile(DataDir, NULL);
+    if (!ControlFile)
+        ereport(ERROR,
+          (errmsg("calculated CRC checksum does not match value stored in file")));
+    snprintf(sysident_str, sizeof (sysident_str), UINT64_FORMAT, ControlFile->system_identifier);
 
-	return sysident_str;
+    return sysident_str;
 }
 
 #ifdef PG_MODULE_MAGIC
@@ -51,9 +51,9 @@ PG_FUNCTION_INFO_V1(postmaster_uptime);
 Datum
 postmaster_uptime(PG_FUNCTION_ARGS)
 {
-	char pid[256];
-	sprintf(pid, "%d", getppid());
-	PG_RETURN_TEXT_P(cstring_to_text(pid));
+    char pid[256];
+    sprintf(pid, "%d", getppid());
+    PG_RETURN_TEXT_P(cstring_to_text(pid));
 }
 
 PG_FUNCTION_INFO_V1(db_sys_id);
@@ -61,9 +61,9 @@ PG_FUNCTION_INFO_V1(db_sys_id);
 Datum
 db_sys_id(PG_FUNCTION_ARGS)
 {
-	char *id;
-	id = system_db_id();
-	PG_RETURN_TEXT_P(cstring_to_text(id));
+    char *id;
+    id = system_db_id();
+    PG_RETURN_TEXT_P(cstring_to_text(id));
 }
 
 PG_FUNCTION_INFO_V1(datadir_fs);
@@ -71,9 +71,9 @@ PG_FUNCTION_INFO_V1(datadir_fs);
 Datum
 datadir_fs(PG_FUNCTION_ARGS)
 {
-	char *fs;
-	fs = dirfs(DataDir);
-	PG_RETURN_TEXT_P(cstring_to_text(fs));
+    char *fs;
+    fs = dirfs(DataDir);
+    PG_RETURN_TEXT_P(cstring_to_text(fs));
 }
 
 PG_FUNCTION_INFO_V1(sysinfo);
@@ -81,61 +81,62 @@ PG_FUNCTION_INFO_V1(sysinfo);
 Datum
 sysinfo(PG_FUNCTION_ARGS)
 {
-	char **values;
-	HeapTuple tuple;
-	Datum result;
-	TupleDesc tupdesc;
-	AttInMetadata *attinmeta;
-	hwinfo *hw;
-	osinfo *os;
+    char **values;
+    HeapTuple tuple;
+    Datum result;
+    TupleDesc tupdesc;
+    AttInMetadata *attinmeta;
+    hwinfo *hw;
+    osinfo *os;
 
-	if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
-		ereport(ERROR,
-		    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-		    errmsg("function returning record called in context "
-		    "that cannot accept type record")));
+    if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
+        ereport(ERROR,
+            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+            errmsg("function returning record called in context "
+            "that cannot accept type record")));
+    }
 
-	values = (char **)palloc(7 * sizeof (char *));
-	values[0] = (char *)palloc(256 * sizeof (char));
-	values[1] = (char *)palloc(256 * sizeof (char));
-	values[2] = (char *)palloc(256 * sizeof (char));
-	values[3] = (char *)palloc(256 * sizeof (char));
-	values[4] = (char *)palloc(256 * sizeof (char));
-	values[5] = (char *)palloc(256 * sizeof (char));
-	values[6] = (char *)palloc(256 * sizeof (char));
+    values = (char **)palloc(7 * sizeof (char *));
+    values[0] = (char *)palloc(256 * sizeof (char));
+    values[1] = (char *)palloc(256 * sizeof (char));
+    values[2] = (char *)palloc(256 * sizeof (char));
+    values[3] = (char *)palloc(256 * sizeof (char));
+    values[4] = (char *)palloc(256 * sizeof (char));
+    values[5] = (char *)palloc(256 * sizeof (char));
+    values[6] = (char *)palloc(256 * sizeof (char));
 
-	hw = get_hw_info();
-	snprintf(values[0], 256, "%d", hw->ncpu);
-	snprintf(values[1], 256, "%" PRId64, hw->memsize);
-	snprintf(values[2], 256, "%llu", hw->uptime);
-	free(hw);
+    hw = get_hw_info();
+    snprintf(values[0], 256, "%d", hw->ncpu);
+    snprintf(values[1], 256, "%" PRId64, hw->memsize);
+    snprintf(values[2], 256, "%llu", hw->uptime);
+    free(hw);
 
-	os = get_os_info();
-	snprintf(values[3], 256, "%s", os->os_version);
-	snprintf(values[4], 256, "%s", os->os_name);
-	snprintf(values[5], 256, "%s", os->os_family);
-	snprintf(values[6], 256, "%s", os->os_arch);
-	free(os->os_version);
-	free(os->os_name);
-	free(os->os_family);
-	free(os->os_arch);
-	free(os);
+    os = get_os_info();
+    snprintf(values[3], 256, "%s", os->os_version);
+    snprintf(values[4], 256, "%s", os->os_name);
+    snprintf(values[5], 256, "%s", os->os_family);
+    snprintf(values[6], 256, "%s", os->os_arch);
+    free(os->os_version);
+    free(os->os_name);
+    free(os->os_family);
+    free(os->os_arch);
+    free(os);
 
-	/* build a tuple */
-	attinmeta = TupleDescGetAttInMetadata(tupdesc);
-	tuple = BuildTupleFromCStrings(attinmeta, values);
+    /* build a tuple */
+    attinmeta = TupleDescGetAttInMetadata(tupdesc);
+    tuple = BuildTupleFromCStrings(attinmeta, values);
 
-	/* make the tuple into a datum */
-	result = HeapTupleGetDatum(tuple);
+    /* make the tuple into a datum */
+    result = HeapTupleGetDatum(tuple);
 
-	/* clean up (this is not really necessary) */
-	pfree(values[0]);
-	pfree(values[1]);
-	pfree(values[2]);
-	pfree(values[3]);
-	pfree(values[4]);
-	pfree(values[5]);
-	pfree(values[6]);
-	pfree(values);
-	PG_RETURN_DATUM(result);
+    /* clean up (this is not really necessary) */
+    pfree(values[0]);
+    pfree(values[1]);
+    pfree(values[2]);
+    pfree(values[3]);
+    pfree(values[4]);
+    pfree(values[5]);
+    pfree(values[6]);
+    pfree(values);
+    PG_RETURN_DATUM(result);
 }
blob - bce7bf78839e4efa3d1c9d76bdc53687eff4f117
blob + 998dce79658a2e373327f8f9f21448306f86f98f
--- tests.c
+++ tests.c
@@ -9,59 +9,58 @@
 
 static void test_get_hw_info(void **state)
 {
-  hwinfo *hw = NULL;
-  hw = malloc(sizeof(hwinfo));
-  assert_non_null(hw);
-  hw = get_hw_info();
-  assert_int_not_equal(hw->ncpu, 0);
-  assert_int_not_equal(hw->memsize, 0);
-  assert_int_not_equal(hw->uptime, 0);
+    hwinfo *hw = NULL;
+    hw = malloc(sizeof(hwinfo));
+    assert_non_null(hw);
+    hw = get_hw_info();
+    assert_int_not_equal(hw->ncpu, 0);
+    assert_int_not_equal(hw->memsize, 0);
+    assert_int_not_equal(hw->uptime, 0);
 }
 
 static void test_get_os_info(void **state)
 {
-  osinfo *os = malloc(sizeof(osinfo));
-  assert_non_null(os);
-  os = get_os_info();
-  assert_string_not_equal(os->os_version, "");
-  assert_string_not_equal(os->os_family, "");
-  assert_string_not_equal(os->os_name, "");
-  assert_string_not_equal(os->os_arch, "");
+    osinfo *os = malloc(sizeof(osinfo));
+    assert_non_null(os);
+    os = get_os_info();
+    assert_string_not_equal(os->os_version, "");
+    assert_string_not_equal(os->os_family, "");
+    assert_string_not_equal(os->os_name, "");
+    assert_string_not_equal(os->os_arch, "");
 }
 
 static void test_dirfs(void **state)
 {
-  char *p = dirfs("/");
-  assert_string_not_equal(p, "");
+    char *p = dirfs("/");
+    assert_string_not_equal(p, "");
 }
 
 #ifdef __linux__
 static void test_lookup_fstype(void **state)
 {
-  char *type = lookup_fstype(1);
-  assert_string_equal(type, "<fs type unknown>");
+    char *type = lookup_fstype(1);
+    assert_string_equal(type, "<fs type unknown>");
 }
 #endif
 
 static void test_get_proc_uptime(void **state)
 {
-  pid_t pid = 1;
-  long long int t = 0;
-  t = get_proc_uptime(pid);
-  assert_int_not_equal(t, 0);
+    pid_t pid = 1;
+    long long int t = 0;
+    t = get_proc_uptime(pid);
+    assert_int_not_equal(t, 0);
 }
 
 int main(void){
-
-  const struct CMUnitTest tests[] = {
-    cmocka_unit_test(test_get_hw_info),
-    cmocka_unit_test(test_get_os_info),
-    cmocka_unit_test(test_get_proc_uptime),
-    cmocka_unit_test(test_dirfs),
+    const struct CMUnitTest tests[] = {
+        cmocka_unit_test(test_get_hw_info),
+        cmocka_unit_test(test_get_os_info),
+        cmocka_unit_test(test_get_proc_uptime),
+        cmocka_unit_test(test_dirfs),
 #ifdef __linux__
-    cmocka_unit_test(test_lookup_fstype),
+        cmocka_unit_test(test_lookup_fstype),
 #endif
-  };
+    };
 
-  return cmocka_run_group_tests(tests, NULL, NULL);
+    return cmocka_run_group_tests(tests, NULL, NULL);
 }