ports/131977: sysutils/wmcube-gdk Fix run on 8-CURRENT and 7-STABLE [PATCH]
Dmitry
dmitry2006 at yandex.ru
Sun Feb 22 16:10:02 UTC 2009
>Number: 131977
>Category: ports
>Synopsis: sysutils/wmcube-gdk Fix run on 8-CURRENT and 7-STABLE [PATCH]
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Feb 22 16:10:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Dmitry
>Release: FreeBSD 7.1-STABLE amd64
>Organization:
>Environment:
FreeBSD *** 7.1-STABLE FreeBSD 7.1-STABLE #0: Sat Feb 21 04:30:04 YEKT 2009 root@***:/usr/src/sys/GENERIC_ amd64
>Description:
Fix run on 8-CURRENT and 7-STABLE
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- wmcube.c.orig2 2008-04-11 21:33:00.000000000 +0600
+++ wmcube.c 2008-04-11 21:38:48.000000000 +0600
@@ -174,6 +174,7 @@
#ifdef FREEBSD
static kvm_t *kd;
static struct nlist nlst[] = { {"_cp_time"}, {0} };
+static int cp_time_mib[2];
#endif
void prep_digits(void)
@@ -226,7 +227,7 @@
XWMHints wmhints;
/* for mask */
GdkBitmap *mask;
- unsigned char mask_data[8 * 64];
+ gchar mask_data[8 * 64];
int i;
GdkColor bright;
/* for that stupid shadow line */
@@ -899,7 +900,8 @@
while ((i > -1) && (temparr[i] > key)) {
temparr[i + 1] = temparr[i];
- zorder[i + 1] = zorder[i--];
+ zorder[i + 1] = zorder[i];
+ i--;
}
zorder[i + 1] = k;
@@ -1297,23 +1299,23 @@
planesORlines = 0;
while (1) {
-
cline = (int *) realloc(cline, (i + 2) * sizeof(int));
mem_alloc_error(cline);
- fscanf(fp, "%d %d", &cline[i++], &cline[i++]);
- /* printf("\n%d %d",cline[i-2],cline[i-1]); */
+ fscanf(fp, "%d %d", &cline[i], &cline[i+1]);
+ /* printf("\n%d %d",cline[i],cline[i+1]); */
if (feof(fp))
break;
- if (cline[i - 2] > nofcoords || cline[i - 1] > nofcoords) {
+ if (cline[i] > nofcoords || cline[i+1] > nofcoords) {
printf("\nError in objectfile (WMCUBE_LINES section):\n"
"coordinates %d or/and %d doesnt exist\n\n",
- cline[i - 2], cline[i - 1]);
+ cline[i], cline[i+1]);
fclose(fp);
exit(0);
}
+ i = i + 2;
}
- noflines = i - 2;
+ noflines = i;
} else if (strcmp(tmp, "WMCUBE_PLANES") == 0) {
planesORlines = 1;
@@ -1582,18 +1583,23 @@
#include <nlist.h>
#include <fcntl.h>
#include <sys/dkstat.h>
+#include <sys/sysctl.h>
int init_calc_cpu()
{
+ size_t len = 2;
+ if (sysctlnametomib("kern.cp_time", cp_time_mib, &len) < 0) {
+ printf("\nWarning: unable to sysctl kern.cp_time\n\n");
- if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) {
- printf("\nError: unable to open kvm\n\n");
- exit(0);
- }
- kvm_nlist(kd, nlst);
- if (nlst[0].n_type == 0) {
- printf("\nError: unable to get nlist\n\n");
- exit(1);
+ if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) {
+ printf("\nError: unable to open kvm\n\n");
+ exit(0);
+ }
+ kvm_nlist(kd, nlst);
+ if (nlst[0].n_type == 0) {
+ printf("\nError: unable to get nlist\n\n");
+ exit(1);
+ }
}
/* drop setgid & setuid (hi GOBBLES, who the fuck are you? */
@@ -1615,6 +1621,13 @@
int cpu, nice, system, idle;
unsigned long int cpu_time[CPUSTATES];
+ if (cp_time_mib[0] != 0) {
+ size_t cpu_time_len = sizeof (cpu_time);
+ if (sysctl(cp_time_mib, 2, cpu_time, &cpu_time_len, NULL, 0) < 0) {
+ printf("\nError sysctl\n\n");
+ exit(0);
+ }
+ } else
if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time))
!= sizeof(cpu_time)) {
printf("\nError reading kvm\n\n");
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list