Module Name: xsrc
Committed By: mrg
Date: Sat Nov 16 08:49:09 UTC 2024
Modified Files:
xsrc/external/mit/x11perf/dist: x11perf.c
xsrc/external/mit/xfs/dist/os: connection.c io.c
xsrc/external/mit/xfs/include: config.h
xsrc/external/mit/xrandr/dist: xrandr.c
xsrc/external/mit/xtrans/dist: Xtrans.c Xtranssock.c
Log Message:
merge x11perf 1.7.0, xfs 1.2.2, xrandr 1.5.3, and xtrans 1.5.2.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/x11perf/dist/x11perf.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xfs/dist/os/connection.c
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xfs/dist/os/io.c
cvs rdiff -u -r1.6 -r1.7 xsrc/external/mit/xfs/include/config.h
cvs rdiff -u -r1.15 -r1.16 xsrc/external/mit/xrandr/dist/xrandr.c
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xtrans/dist/Xtrans.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xtrans/dist/Xtranssock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/x11perf/dist/x11perf.c
diff -u xsrc/external/mit/x11perf/dist/x11perf.c:1.3 xsrc/external/mit/x11perf/dist/x11perf.c:1.4
--- xsrc/external/mit/x11perf/dist/x11perf.c:1.3 Sun Nov 13 02:48:37 2022
+++ xsrc/external/mit/x11perf/dist/x11perf.c Sat Nov 16 08:49:08 2024
@@ -3,13 +3,13 @@ Copyright 1988, 1989 by Digital Equipmen
All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
+both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
+software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -161,7 +161,7 @@ static int ssTimeout, ssInterval, ssPref
/* Static functions */
static int GetWords(int argi, int argc, char **argv, char **wordsp, int *nump);
-static int GetNumbers(int argi, int argc, char **argv, unsigned long *intsp,
+static int GetNumbers(int argi, int argc, char **argv, unsigned long *intsp,
int *nump);
static int GetRops(int argi, int argc, char **argv, int *ropsp, int *nump);
static int GetPops(int argi, int argc, char **argv, int *popsp, int *nump);
@@ -221,7 +221,7 @@ int gettimeofday(tp)
static struct timeval start;
-static void
+static void
PrintTime(void)
{
Time_t t;
@@ -230,13 +230,13 @@ PrintTime(void)
printf("%s\n", ctime(&t));
}
-static void
+static void
InitTimes(void)
{
X_GETTIMEOFDAY(&start);
}
-static double
+static double
ElapsedTime(double correction)
{
struct timeval stop;
@@ -250,7 +250,7 @@ ElapsedTime(double correction)
(1000000.0 * (double)(stop.tv_sec - start.tv_sec)) - correction;
}
-static double
+static double
RoundTo3Digits(double d)
{
/* It's kind of silly to print out things like ``193658.4/sec'' so just
@@ -286,7 +286,7 @@ RoundTo3Digits(double d)
}
-static void
+static void
ReportTimes(double usecs, int64_t n, char *str, int average)
{
if(usecs != 0.0)
@@ -299,10 +299,10 @@ ReportTimes(double usecs, int64_t n, cha
objspersec = RoundTo3Digits(objspersec);
if (average) {
- printf("%11lld trep @ %8.4f msec (%8.1f/sec): %s\n",
+ printf("%11lld trep @ %8.4f msec (%8.1f/sec): %s\n",
(long long) n, msecsperobj, objspersec, str);
} else {
- printf("%11lld reps @ %8.4f msec (%8.1f/sec): %s\n",
+ printf("%11lld reps @ %8.4f msec (%8.1f/sec): %s\n",
(long long) n, msecsperobj, objspersec, str);
}
} else {
@@ -319,7 +319,26 @@ ReportTimes(double usecs, int64_t n, cha
************************************************/
static char *program_name;
-static void usage(void) _X_NORETURN;
+typedef enum {
+ USAGE_OPTIONS,
+ USAGE_TESTS,
+ USAGE_ALL
+} usage_contents;
+_X_NORETURN _X_COLD static void usage(usage_contents, int);
+
+_X_NORETURN _X_COLD static void
+missing_arg(const char *option)
+{
+ fprintf(stderr, "Error: missing argument to %s\n", option);
+ usage(USAGE_OPTIONS, EXIT_FAILURE);
+}
+
+_X_NORETURN _X_COLD static void
+invalid_arg( const char *arg, const char *option)
+{
+ fprintf(stderr, "Error: invalid argument '%s' to %s\n", arg, option);
+ usage(USAGE_OPTIONS, EXIT_FAILURE);
+}
/*
* Get_Display_Name (argc, argv) Look for -display, -d, or host:dpy (obsolete)
@@ -337,7 +356,8 @@ Get_Display_Name(int *pargc, /* MODIFIED
char *arg = argv[i];
if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
- if (++i >= argc) usage ();
+ if (++i >= argc)
+ missing_arg(arg);
displayname = argv[i];
*pargc -= 2;
@@ -356,59 +376,64 @@ Get_Display_Name(int *pargc, /* MODIFIED
/*
- * GetVersion (argc, argv) Look for -v1.2, -v1.3, or -v1.4.
+ * GetVersion (argc, argv) Look for -v followed by a version number.
* If found remove it from command line. Don't go past a lone -.
+ * Leave -v followed by non-numbers as it could be -vclass or -version.
*/
-static Version
+static Version
GetVersion(int *pargc, /* MODIFIED */
char **argv) /* MODIFIED */
{
int argc = *pargc;
char **pargv = argv+1;
- Version version = VERSION1_6;
+ Version version = VERSION1_7;
Bool found = False;
for (int i = 1; i != argc; i++) {
char *arg = argv[i];
- if (!strcmp (arg, "-v1.2")) {
- version = VERSION1_2;
- *pargc -= 1;
- if (found) {
- fprintf(stderr, "Warning: multiple version specifications\n");
- }
- found = True;
- continue;
- }
- if (!strcmp (arg, "-v1.3")) {
- version = VERSION1_3;
- *pargc -= 1;
- if (found) {
- fprintf(stderr, "Warning: multiple version specifications\n");
- }
- found = True;
- continue;
- }
- if (!strcmp (arg, "-v1.4")) {
- version = VERSION1_4;
- *pargc -= 1;
- if (found) {
- fprintf(stderr, "Warning: multiple version specifications\n");
- }
- found = True;
- continue;
- }
- if (!strcmp (arg, "-v1.5")) {
- version = VERSION1_5;
- *pargc -= 1;
- if (found) {
- fprintf(stderr, "Warning: multiple version specifications\n");
+ if (arg[0] == '-' && arg[1] == 'v') {
+ if (arg[2] == '1' && arg[3] == '.' && arg[5] == '\0') {
+ switch (arg[4]) {
+ case '2':
+ version = VERSION1_2;
+ break;
+ case '3':
+ version = VERSION1_3;
+ break;
+ case '4':
+ version = VERSION1_4;
+ break;
+ case '5':
+ version = VERSION1_5;
+ break;
+ case '6':
+ version = VERSION1_6;
+ break;
+ case '7':
+ version = VERSION1_7;
+ break;
+ default:
+ goto unknown_version;
+ }
+
+ if (found) {
+ fprintf(stderr, "Warning: multiple version specifications\n");
+ }
+ found = True;
+
+ /* reduce arg count and skip copying this arg to pargv */
+ *pargc -= 1;
+ continue;
+ } else if (isdigit(arg[2])) {
+ unknown_version:
+ fprintf(stderr, "Error: unknown version specification: %s\n",
+ arg);
+ exit(1);
}
- found = True;
- continue;
}
- if (!strcmp(arg,"-")) {
+ else if (!strcmp(arg,"-")) {
while (i<argc) *pargv++ = argv[i++];
break;
}
@@ -449,7 +474,7 @@ void
AbortTest(void)
{
fflush(stdout);
-
+
XSetScreenSaver(xparms.d, ssTimeout, ssInterval, ssPreferBlanking,
ssAllowExposures);
XFlush(xparms.d);
@@ -461,8 +486,8 @@ AbortTest(void)
************************************************/
-static void
-usage(void)
+static void
+usage(usage_contents show, int exit_status)
{
int i = 0;
static const char *help_message =
@@ -479,10 +504,10 @@ usage(void)
" -all do all tests\n"
" -range <test1>[,<test2>] like all, but do <test1> to <test2>\n"
" -labels generate test labels for use by fillblnk\n"
-" -fg the foreground color to use\n"
-" -bg the background color to use\n"
+" -fg <color-or-pixel> the foreground color to use\n"
+" -bg <color-or-pixel> the background color to use\n"
" -clips <default> default number of clip windows per test\n"
-" -ddbg the background color to use for DoubleDash\n"
+" -ddbg <color-or-pixel> the background color to use for DoubleDash\n"
" -rop <rop0 rop1 ...> use the given rops to draw (default = GXcopy)\n"
" -pm <pm0 pm1 ...> use the given planemasks to draw (default = ~0)\n"
" -depth <depth> use a visual with <depth> planes per pixel\n"
@@ -491,42 +516,48 @@ usage(void)
" -subs <s0 s1 ...> a list of the number of sub-windows to use\n"
" -v1.2 perform only v1.2 tests using old semantics\n"
" -v1.3 perform only v1.3 tests using old semantics\n"
+" -v1.4 perform only v1.4 tests using old semantics\n"
+" -v1.5 perform only v1.5 tests using old semantics\n"
+" -v1.6 perform only v1.6 tests using old semantics\n"
+" -v1.7 perform only v1.7 tests using old semantics\n"
+" -version print version and exit\n"
" -su request save unders on windows\n"
" -bs <backing_store_hint> WhenMapped or Always (default = NotUseful)\n"
+" -help [options|tests|all] list general options, test options, or both\n"
;
fflush(stdout);
- fprintf(stderr, "usage: %s [-options ...]\n%s", program_name, help_message);
- while (test[i].option != NULL) {
- if (test[i].versions & xparms.version ) {
- fprintf(stderr, " %-24s %s\n",
- test[i].option,
- test[i].label14 ? test[i].label14 : test[i].label);
- }
- i++;
+ if (show == USAGE_OPTIONS || show == USAGE_ALL) {
+ fprintf(stderr, "usage: %s [-options ...]\n%s",
+ program_name, help_message);
+ }
+ if (show == USAGE_TESTS || show == USAGE_ALL) {
+ while (test[i].option != NULL) {
+ if (test[i].versions & xparms.version ) {
+ fprintf(stderr, " %-24s %s\n",
+ test[i].option,
+ test[i].label14 ? test[i].label14 : test[i].label);
+ }
+ i++;
+ }
}
fprintf(stderr, "\n");
-
- /* Print out original command line as the above usage message is so long */
- for (i = 0; i != saveargc; i++) {
- fprintf(stderr, "%s ", saveargv[i]);
- }
- fprintf(stderr, "\n\n");
- exit (1);
+
+ exit (exit_status);
}
-void
+void
NullProc(XParms xp, Parms p)
{
}
-int
+int
NullInitProc(XParms xp, Parms p, int64_t reps)
{
return reps;
}
-static void
+static void
HardwareSync(XParms xp)
{
/*
@@ -537,13 +568,13 @@ HardwareSync(XParms xp)
*/
XImage *image;
- image = XGetImage(xp->d, xp->p ? xp->p : xp->w, HSx, HSy,
+ image = XGetImage(xp->d, xp->p ? xp->p : xp->w, HSx, HSy,
1, 1, ~0, ZPixmap);
if (image) XDestroyImage(image);
}
-static void
-DoHardwareSync(XParms xp, Parms p, int64_t reps)
+static void
+DoHardwareSync(XParms xp, Parms p, int64_t reps)
{
for (int i = 0; i != reps; i++) {
HardwareSync(xp);
@@ -553,13 +584,13 @@ DoHardwareSync(XParms xp, Parms p, int64
static Test syncTest = {
"syncTime", "Internal test for finding how long HardwareSync takes", NULL,
- NullInitProc, DoHardwareSync, NullProc, NullProc,
+ NullInitProc, DoHardwareSync, NullProc, NullProc,
V1_2FEATURE, NONROP, 0,
{1}
};
-static Window
+static Window
CreatePerfWindow(XParms xp, int x, int y, int width, int height)
{
XSetWindowAttributes xswa;
@@ -584,14 +615,14 @@ CreatePerfWindow(XParms xp, int x, int y
xswa.save_under = xp->save_under;
w = XCreateWindow(xp->d, DefaultRootWindow(xp->d), x, y, width, height, 1,
xp->vinfo.depth, CopyFromParent, xp->vinfo.visual,
- CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect
+ CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect
| CWBackingStore | CWSaveUnder, &xswa);
XMapWindow (xp->d, w);
return w;
}
-static void
+static void
CreateClipWindows(XParms xp, int clips)
{
XWindowAttributes xwa;
@@ -605,7 +636,7 @@ CreateClipWindows(XParms xp, int clips)
} /* CreateClipWindows */
-static void
+static void
DestroyClipWindows(XParms xp, int clips)
{
if (clips > MAXCLIP) clips = MAXCLIP;
@@ -615,7 +646,7 @@ DestroyClipWindows(XParms xp, int clips)
} /* DestroyClipWindows */
-static double
+static double
DoTest(XParms xp, Test *test, int64_t reps)
{
double time;
@@ -624,7 +655,7 @@ DoTest(XParms xp, Test *test, int64_t re
/* Tell screen-saver to restart counting again. See comments below for the
XSetScreenSaver call. */
XForceScreenSaver(xp->d, ScreenSaverReset);
- HardwareSync (xp);
+ HardwareSync (xp);
InitTimes ();
(*test->proc) (xp, &test->parms, reps);
HardwareSync(xp);
@@ -685,9 +716,9 @@ CalibrateTest(XParms xp, Test *test, int
CheckAbort ();
if (didreps != reps) {
- /* The test can't do the number of reps as we asked for.
+ /* The test can't do the number of reps as we asked for.
Give up */
- *usecperobj =
+ *usecperobj =
usecs / (double)(didreps * test->parms.objects);
return didreps;
}
@@ -717,7 +748,7 @@ CalibrateTest(XParms xp, Test *test, int
return reps;
} /* CalibrateTest */
-static void
+static void
CreatePerfGCs(XParms xp, int func, unsigned long pm)
{
XGCValues gcvfg, gcvbg, gcvddbg,gcvddfg;
@@ -738,40 +769,31 @@ CreatePerfGCs(XParms xp, int func, unsig
gcvbg.function = func;
gcvddfg.function = func;
gcvddbg.function = func;
-
- if (func == GXxor) {
- /* Make test look good visually if possible */
- gcvbg.foreground = gcvfg.foreground = bg ^ fg;
- gcvbg.background = gcvfg.background = bg;
- /* Double Dash GCs (This doesn't make a huge amount of sense) */
- gcvddbg.foreground = gcvddfg.foreground = bg ^ fg;
- gcvddbg.background = gcvddfg.foreground = bg ^ ddbg;
- } else {
- gcvfg.foreground = fg;
- gcvfg.background = bg;
- gcvbg.foreground = bg;
- gcvbg.background = fg;
- gcvddfg.foreground = fg;
- gcvddfg.background = ddbg;
- gcvddbg.foreground = ddbg;
- gcvddbg.background = fg;
- }
+
+ gcvfg.foreground = fg;
+ gcvfg.background = bg;
+ gcvbg.foreground = bg;
+ gcvbg.background = fg;
+ gcvddfg.foreground = fg;
+ gcvddfg.background = ddbg;
+ gcvddbg.foreground = ddbg;
+ gcvddbg.background = fg;
xp->fggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures
| GCFunction | GCPlaneMask, &gcvfg);
- xp->bggc = XCreateGC(xp->d, xp->w,
+ xp->bggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures
| GCFunction | GCPlaneMask, &gcvbg);
xp->ddfggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures
| GCFunction | GCPlaneMask, &gcvddfg);
- xp->ddbggc = XCreateGC(xp->d, xp->w,
+ xp->ddbggc = XCreateGC(xp->d, xp->w,
GCForeground | GCBackground | GCGraphicsExposures
| GCFunction | GCPlaneMask, &gcvddbg);
}
-static void
+static void
DestroyPerfGCs(XParms xp)
{
XFreeGC(xp->d, xp->fggc);
@@ -780,7 +802,7 @@ DestroyPerfGCs(XParms xp)
XFreeGC(xp->d, xp->ddbggc);
}
-static unsigned long
+static unsigned long
AllocateColor(Display *display, const char *name, unsigned long pixel)
{
XColor color;
@@ -805,7 +827,7 @@ AllocateColor(Display *display, const ch
} /* AllocateColor */
-static void
+static void
DisplayStatus(Display *d, const char *message, const char *test, int try)
{
char s[500];
@@ -818,7 +840,7 @@ DisplayStatus(Display *d, const char *me
}
-static void
+static void
ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
{
double time, totalTime;
@@ -928,9 +950,9 @@ main(int argc, char *argv[])
} else if (strcmp(argv[i], "-range") == 0) {
char *cp1;
char *cp2;
-
+
if (argc <= ++i)
- usage();
+ missing_arg(argv[i-1]);
cp1 = argv[i];
if (*cp1 == '-')
cp1++;
@@ -951,13 +973,19 @@ main(int argc, char *argv[])
} while (!(strcmp(cp2, (test[k].option + 1)) == 0 &&
(test[k].versions & xparms.version)) &&
test[++k].option != NULL);
- if (*cp2 != '-' && test[k].option == NULL)
- usage();
+ if (*cp2 != '-' && test[k].option == NULL) {
+ fprintf(stderr, "Error: unknown test %s listed for %s\n",
+ cp2, argv[i-1]);
+ usage(USAGE_OPTIONS, EXIT_FAILURE);
+ }
break;
}
}
- if (test[j].option == NULL)
- usage();
+ if (test[j].option == NULL) {
+ fprintf(stderr, "Error: unknown test %s listed for %s\n",
+ argv[i], argv[i-1]);
+ usage(USAGE_OPTIONS, EXIT_FAILURE);
+ }
foundOne = True;
} else if (strcmp (argv[i], "-sync") == 0) {
synchronous = True;
@@ -970,44 +998,44 @@ main(int argc, char *argv[])
} else if (strcmp (argv[i], "-repeat") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
repeat = atoi (argv[i]);
if (repeat <= 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp (argv[i], "-time") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
seconds = atoi (argv[i]);
if (seconds <= 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp (argv[i], "-pause") == 0) {
++i;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
delay = atoi (argv[i]);
if (delay < 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp(argv[i], "-fg") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
foreground = argv[i];
} else if (strcmp(argv[i], "-bg") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
background = argv[i];
if(ddbackground == NULL)
ddbackground = argv[i];
} else if (strcmp(argv[i], "-clips") == 0 ) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
clips = atoi( argv[i] );
} else if (strcmp(argv[i], "-ddbg") == 0) {
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
i++;
ddbackground = argv[i];
} else if (strcmp(argv[i], "-rop") == 0) {
@@ -1032,21 +1060,21 @@ main(int argc, char *argv[])
} else if (strcmp(argv[i], "-reps") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
fixedReps = atoi (argv[i]);
if (fixedReps <= 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp(argv[i], "-depth") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
depth = atoi(argv[i]);
if (depth <= 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp(argv[i], "-vclass") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
for (j = StaticGray; j <= DirectColor; j++) {
if (strcmp(argv[i], visualClassNames[j]) == 0) {
vclass = j;
@@ -1054,25 +1082,42 @@ main(int argc, char *argv[])
}
}
if (vclass < 0)
- usage ();
+ invalid_arg(argv[i], argv[i-1]);
} else if (strcmp(argv[i], "-subs") == 0) {
skip = GetNumbers (i+1, argc, argv, subWindows, &numSubWindows);
i += skip;
- } else if (strcmp(argv[i], "-v1.2") == 0) {
- xparms.version = VERSION1_2;
- } else if (strcmp(argv[i], "-v1.3") == 0) {
- xparms.version = VERSION1_3;
} else if (strcmp(argv[i], "-su") == 0) {
xparms.save_under = True;
} else if (strcmp(argv[i], "-bs") == 0) {
i++;
if (argc <= i)
- usage ();
+ missing_arg(argv[i-1]);
if (strcmp(argv[i], "WhenMapped") == 0) {
xparms.backing_store = WhenMapped;
} else if (strcmp(argv[i], "Always") == 0) {
xparms.backing_store = Always;
- } else usage ();
+ } else
+ invalid_arg(argv[i], argv[i-1]);
+ } else if ((strcmp(argv[i], "-version") == 0) ||
+ (strcmp(argv[i], "--version") == 0)) {
+ puts(PACKAGE_STRING);
+ exit(EXIT_SUCCESS);
+ } else if ((strcmp(argv[i], "-help") == 0) ||
+ (strcmp(argv[i], "--help") == 0)) {
+ i++;
+ /* default is to just show general options */
+ if (argc <= i || (strcmp(argv[i], "options") == 0)) {
+ usage (USAGE_OPTIONS, EXIT_SUCCESS);
+ }
+ else if (strcmp(argv[i], "tests") == 0) {
+ usage (USAGE_TESTS, EXIT_SUCCESS);
+ }
+ else if (strcmp(argv[i], "all") == 0) {
+ usage (USAGE_ALL, EXIT_SUCCESS);
+ }
+ else {
+ invalid_arg(argv[i], argv[i-1]);
+ }
} else {
int len,found;
ForEachTest (j) {
@@ -1098,9 +1143,12 @@ main(int argc, char *argv[])
doit[j] = found = True;
}
}
- if(!found)
- usage ();
- LegalOption:
+ if (!found) {
+ fprintf(stderr,
+ "Error: unrecognized option %s\n", argv[i]);
+ usage (USAGE_OPTIONS, EXIT_FAILURE);
+ }
+ LegalOption:
foundOne = True;
}
}
@@ -1114,7 +1162,7 @@ main(int argc, char *argv[])
case NONROP:
printf ("%s\n", LABELP(i));
break;
-
+
case ROP:
/* Run it through all specified rops and planemasks */
for (rop = 0; rop < numRops; rop++) {
@@ -1136,7 +1184,7 @@ main(int argc, char *argv[])
} /* for pm */
} /* for rop */
break;
-
+
case PLANEMASK:
/* Run it through all specified planemasks */
for (pm = 0; pm < numPlanemasks; pm++) {
@@ -1149,7 +1197,7 @@ main(int argc, char *argv[])
}
} /* for pm */
break;
-
+
case WINDOW:
for (int child = 0; child != numSubWindows; child++) {
printf ("%s (%ld kids)\n",
@@ -1174,8 +1222,10 @@ main(int argc, char *argv[])
exit(0);
}
- if (!foundOne)
- usage ();
+ if (!foundOne) {
+ fprintf(stderr, "Error: no argument found for which test(s) to run\n");
+ usage (USAGE_OPTIONS, EXIT_FAILURE);
+ }
xparms.d = Open_Display (displayName);
screen = DefaultScreen(xparms.d);
@@ -1233,7 +1283,7 @@ main(int argc, char *argv[])
}
}
xparms.cmap = cmap;
-
+
printf("x11perf - X11 performance program, version %s\n",
xparms.version & VERSION1_5 ? "1.5" :
xparms.version & VERSION1_4 ? "1.4" :
@@ -1251,7 +1301,7 @@ main(int argc, char *argv[])
saver off, but this causes problems on some servers. We also reset
the screen-saver timer each test, as 8 hours is about the maximum time
we can use, and that isn't long enough for some X terminals using a
- serial protocol to finish all the tests. As long as the tests run to
+ serial protocol to finish all the tests. As long as the tests run to
completion, the old screen-saver values are restored. */
XForceScreenSaver(xparms.d, ScreenSaverReset);
XGetScreenSaver(xparms.d, &ssTimeout, &ssInterval, &ssPreferBlanking,
@@ -1264,7 +1314,7 @@ main(int argc, char *argv[])
#ifdef SIGHUP
(void) signal(SIGHUP, Cleanup);
#endif
- XSetScreenSaver(xparms.d, 8 * 3600, ssInterval, ssPreferBlanking,
+ XSetScreenSaver(xparms.d, 8 * 3600, ssInterval, ssPreferBlanking,
ssAllowExposures);
if (drawToFakeServer) {
@@ -1292,13 +1342,13 @@ main(int argc, char *argv[])
HSy = HEIGHT-1;
if (window_y + 1 + HEIGHT > DisplayHeight(xparms.d, screen))
HSy = DisplayHeight(xparms.d, screen) - (1 + window_y + 1);
- status = CreatePerfWindow(&xparms, window_x, HEIGHT+5, WIDTH, 20);
- tgcv.foreground =
+ status = CreatePerfWindow(&xparms, window_x, window_y + HEIGHT+3, WIDTH, 20);
+ tgcv.foreground =
AllocateColor(xparms.d, "black", BlackPixel(xparms.d, screen));
- tgcv.background =
+ tgcv.background =
AllocateColor(xparms.d, "white", WhitePixel(xparms.d, screen));
tgc = XCreateGC(xparms.d, status, GCForeground | GCBackground, &tgcv);
-
+
xparms.p = (Pixmap)0;
if (synchronous)
@@ -1306,7 +1356,7 @@ main(int argc, char *argv[])
/* Get mouse pointer out of the way of the performance window. On
software cursor machines it will slow graphics performance. On
- all current MIT-derived servers it will slow window
+ all current MIT-derived servers it will slow window
creation/configuration performance. */
XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH+32, 20+32);
@@ -1349,7 +1399,7 @@ main(int argc, char *argv[])
} /* for pm */
} /* for rop */
break;
-
+
case PLANEMASK:
/* Run it through all specified planemasks */
for (pm = 0; pm < numPlanemasks; pm++) {
@@ -1364,7 +1414,7 @@ main(int argc, char *argv[])
planemasks[pm], label);
} /* for pm */
break;
-
+
case WINDOW:
/* Loop through number of children array */
for (int child = 0; child != numSubWindows; child++) {
@@ -1421,7 +1471,7 @@ GetWords (int argi, int argc, char **arg
int count;
if (argc <= argi)
- usage();
+ missing_arg(argv[argi-1]);
count = 0;
while (argv[argi] && *(argv[argi]) != '-') {
*wordsp++ = argv[argi];
@@ -1496,7 +1546,7 @@ GetRops (int argi, int argc, char **argv
}
}
if (rop == NUM_ROPS) {
- usage ();
+ usage (USAGE_OPTIONS, EXIT_FAILURE);
fprintf (stderr, "unknown rop name %s\n", words[i]);
}
}
@@ -1528,7 +1578,7 @@ GetPops (int argi, int argc, char **argv
}
}
if (pop == NUM_POPS) {
- usage ();
+ usage (USAGE_OPTIONS, EXIT_FAILURE);
fprintf (stderr, "unknown picture op name %s\n", words[i]);
}
}
@@ -1573,7 +1623,7 @@ GetFormats (int argi, int argc, char **a
}
format = FormatFromName (words[i]);
if (format < 0) {
- usage ();
+ usage (USAGE_OPTIONS, EXIT_FAILURE);
fprintf (stderr, "unknown format name %s\n", words[i]);
}
formatsp[i] = format;
Index: xsrc/external/mit/xfs/dist/os/connection.c
diff -u xsrc/external/mit/xfs/dist/os/connection.c:1.4 xsrc/external/mit/xfs/dist/os/connection.c:1.5
--- xsrc/external/mit/xfs/dist/os/connection.c:1.4 Mon Jul 11 08:42:42 2022
+++ xsrc/external/mit/xfs/dist/os/connection.c Sat Nov 16 08:49:08 2024
@@ -325,9 +325,9 @@ MakeNewConnections(void)
_FontTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
- oc = (OsCommPtr) fsalloc(sizeof(OsCommRec));
+ oc = (OsCommPtr) FSalloc(sizeof(OsCommRec));
if (!oc) {
- fsfree(oc);
+ FSfree(oc);
error_conn_max(new_trans_conn);
_FontTransClose(new_trans_conn);
continue;
@@ -431,7 +431,7 @@ close_fd(OsCommPtr oc)
if (!XFD_ANYSET(&ClientsWriteBlocked))
AnyClientsWriteBlocked = FALSE;
FD_CLR(fd, &OutputPending);
- fsfree(oc);
+ FSfree(oc);
}
void
Index: xsrc/external/mit/xfs/dist/os/io.c
diff -u xsrc/external/mit/xfs/dist/os/io.c:1.3 xsrc/external/mit/xfs/dist/os/io.c:1.4
--- xsrc/external/mit/xfs/dist/os/io.c:1.3 Sun Mar 11 10:08:03 2018
+++ xsrc/external/mit/xfs/dist/os/io.c Sat Nov 16 08:49:09 2024
@@ -135,8 +135,8 @@ ReadRequest(ClientPtr client)
ConnectionInputPtr aci = AvailableInput->input;
if (aci->size > BUFWATERMARK) {
- fsfree(aci->buffer);
- fsfree(aci);
+ FSfree(aci->buffer);
+ FSfree(aci);
} else {
aci->next = FreeInputs;
FreeInputs = aci;
@@ -179,7 +179,7 @@ ReadRequest(ClientPtr client)
if (needed > oci->size) {
char *ibuf;
- ibuf = (char *) fsrealloc(oci->buffer, needed);
+ ibuf = (char *) FSrealloc(oci->buffer, needed);
if (!ibuf) {
yield_control_death();
return -1;
@@ -218,7 +218,7 @@ ReadRequest(ClientPtr client)
(oci->bufcnt < BUFSIZE) && (needed < BUFSIZE)) {
char *ibuf;
- ibuf = (char *) fsrealloc(oci->buffer, BUFSIZE);
+ ibuf = (char *) FSrealloc(oci->buffer, BUFSIZE);
if (ibuf) {
oci->size = BUFSIZE;
oci->buffer = ibuf;
@@ -275,8 +275,8 @@ InsertFakeRequest(ClientPtr client, char
register ConnectionInputPtr aci = AvailableInput->input;
if (aci->size > BUFWATERMARK) {
- fsfree(aci->buffer);
- fsfree(aci);
+ FSfree(aci->buffer);
+ FSfree(aci);
} else {
aci->next = FreeInputs;
FreeInputs = aci;
@@ -299,7 +299,7 @@ InsertFakeRequest(ClientPtr client, char
if ((gotnow + count) > oci->size) {
char *ibuf;
- ibuf = (char *) fsrealloc(oci->buffer, gotnow + count);
+ ibuf = (char *) FSrealloc(oci->buffer, gotnow + count);
if (!ibuf)
return FALSE;
oci->size = gotnow + count;
@@ -414,9 +414,6 @@ FlushClient(
notWritten -= len;
todo = notWritten;
} else if (ETEST(errno)
-#ifdef SUNSYSV /* check for another brain-damaged OS bug */
- || (errno == 0)
-#endif
#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
|| ((errno == EMSGSIZE) && (todo == 1))
#endif
@@ -441,7 +438,7 @@ FlushClient(
if (notWritten > oco->size) {
unsigned char *obuf;
- obuf = (unsigned char *) fsrealloc(oco->buf,
+ obuf = (unsigned char *) FSrealloc(oco->buf,
notWritten + OutputBufferSize);
if (!obuf) {
if (oc->trans_conn)
@@ -488,8 +485,8 @@ FlushClient(
AnyClientsWriteBlocked = FALSE;
}
if (oco->size > BUFWATERMARK) {
- fsfree(oco->buf);
- fsfree(oco);
+ FSfree(oco->buf);
+ FSfree(oco);
} else {
oco->next = FreeOutputs;
FreeOutputs = oco;
@@ -584,11 +581,13 @@ WriteToClient(ClientPtr client, int coun
int flag = 0;
if (NULL == buf) {
flag = -1;
- buf = (char *)fsalloc(count); memset(buf, 0, count);
+ buf = (char *) FScalloc(1, count);
+ if (buf == NULL)
+ FatalError("WriteToClient couldn't create client buffer\n");
}
- write_to_client_internal(client, count, buf, padlength[count & 3]);
+ write_to_client_internal(client, count, buf, padlength[count & 3]);
if (flag)
- fsfree(buf);
+ FSfree(buf);
}
static ConnectionInputPtr
@@ -596,12 +595,12 @@ AllocateInputBuffer(void)
{
register ConnectionInputPtr oci;
- oci = (ConnectionInputPtr) fsalloc(sizeof(ConnectionInput));
+ oci = (ConnectionInputPtr) FSalloc(sizeof(ConnectionInput));
if (!oci)
return (ConnectionInputPtr) NULL;
- oci->buffer = (char *) fsalloc(BUFSIZE);
+ oci->buffer = (char *) FSalloc(BUFSIZE);
if (!oci->buffer) {
- fsfree(oci);
+ FSfree(oci);
return (ConnectionInputPtr) NULL;
}
oci->next = NULL;
@@ -617,12 +616,12 @@ AllocateOutputBuffer(void)
{
register ConnectionOutputPtr oco;
- oco = (ConnectionOutputPtr) fsalloc(sizeof(ConnectionOutput));
+ oco = (ConnectionOutputPtr) FSalloc(sizeof(ConnectionOutput));
if (!oco)
return (ConnectionOutputPtr) NULL;
- oco->buf = (unsigned char *) fsalloc(BUFSIZE);
+ oco->buf = (unsigned char *) FSalloc(BUFSIZE);
if (!oco->buf) {
- fsfree(oco);
+ FSfree(oco);
return (ConnectionOutputPtr) NULL;
}
oco->size = BUFSIZE;
@@ -641,8 +640,8 @@ FreeOsBuffers(OsCommPtr oc)
AvailableInput = (OsCommPtr) NULL;
if ((oci = oc->input) != (ConnectionInputPtr) 0) {
if (FreeInputs) {
- fsfree(oci->buffer);
- fsfree(oci);
+ FSfree(oci->buffer);
+ FSfree(oci);
} else {
FreeInputs = oci;
oci->next = (ConnectionInputPtr) NULL;
@@ -653,8 +652,8 @@ FreeOsBuffers(OsCommPtr oc)
}
if ((oco = oc->output) != (ConnectionOutputPtr) 0) {
if (FreeOutputs) {
- fsfree(oco->buf);
- fsfree(oco);
+ FSfree(oco->buf);
+ FSfree(oco);
} else {
FreeOutputs = oco;
oco->next = (ConnectionOutputPtr) NULL;
@@ -671,12 +670,12 @@ ResetOsBuffers(void)
while ((oci = FreeInputs) != (ConnectionInputPtr) 0) {
FreeInputs = oci->next;
- fsfree(oci->buffer);
- fsfree(oci);
+ FSfree(oci->buffer);
+ FSfree(oci);
}
while ((oco = FreeOutputs) != (ConnectionOutputPtr) 0) {
FreeOutputs = oco->next;
- fsfree(oco->buf);
- fsfree(oco);
+ FSfree(oco->buf);
+ FSfree(oco);
}
}
Index: xsrc/external/mit/xfs/include/config.h
diff -u xsrc/external/mit/xfs/include/config.h:1.6 xsrc/external/mit/xfs/include/config.h:1.7
--- xsrc/external/mit/xfs/include/config.h:1.6 Tue Jul 12 01:26:29 2022
+++ xsrc/external/mit/xfs/include/config.h Sat Nov 16 08:49:09 2024
@@ -73,7 +73,7 @@
#define PACKAGE_NAME "xfs"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "xfs 1.2.1"
+#define PACKAGE_STRING "xfs 1.2.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "xfs"
@@ -82,7 +82,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.2.1"
+#define PACKAGE_VERSION "1.2.2"
/* Major version of this package */
#define PACKAGE_VERSION_MAJOR 1
@@ -91,7 +91,7 @@
#define PACKAGE_VERSION_MINOR 2
/* Patch version of this package */
-#define PACKAGE_VERSION_PATCHLEVEL 1
+#define PACKAGE_VERSION_PATCHLEVEL 2
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
@@ -196,7 +196,7 @@
/* Version number of package */
-#define VERSION "1.2.1"
+#define VERSION "1.2.2"
/* Build support for starting from inetd */
#define XFS_INETD 1
Index: xsrc/external/mit/xrandr/dist/xrandr.c
diff -u xsrc/external/mit/xrandr/dist/xrandr.c:1.15 xsrc/external/mit/xrandr/dist/xrandr.c:1.16
--- xsrc/external/mit/xrandr/dist/xrandr.c:1.15 Sun Jan 8 09:59:51 2023
+++ xsrc/external/mit/xrandr/dist/xrandr.c Sat Nov 16 08:49:09 2024
@@ -1063,17 +1063,12 @@ set_gamma_info(output_t *output)
if (!output->crtc_info)
return;
- size = XRRGetCrtcGammaSize(dpy, output->crtc_info->crtc.xid);
- if (!size) {
- warning("Failed to get size of gamma for output %s\n", output->output.string);
- return;
- }
-
crtc_gamma = XRRGetCrtcGamma(dpy, output->crtc_info->crtc.xid);
if (!crtc_gamma) {
warning("Failed to get gamma for output %s\n", output->output.string);
return;
}
+ size = crtc_gamma->size;
/*
* Here is a bit tricky because gamma is a whole curve for each
@@ -1691,8 +1686,8 @@ apply (void)
XGrabServer (dpy);
/*
- * Turn off any crtcs which are to be disabled or which are
- * larger than the target size
+ * Turn off any crtcs which are to be disabled or which
+ * need to be updated
*/
for (int c = 0; c < res->ncrtc; c++)
{
@@ -1705,30 +1700,32 @@ apply (void)
/*
* If this crtc is to be left enabled, make
- * sure the old size fits then new screen
+ * sure the new geometry is unchanged and fits
*/
if (crtc->mode_info)
{
XRRModeInfo *old_mode = find_mode_by_xid (crtc_info->mode);
- int x, y, w, h;
- box_t bounds;
+ box_t cur, pending;
if (!old_mode)
panic (RRSetConfigFailed, crtc);
-
- /* old position and size information */
- mode_geometry (old_mode, crtc_info->rotation,
- &crtc->current_transform.transform,
- &bounds);
- x = crtc_info->x + bounds.x1;
- y = crtc_info->y + bounds.y1;
- w = bounds.x2 - bounds.x1;
- h = bounds.y2 - bounds.y1;
+ mode_geometry (old_mode, crtc_info->rotation,
+ &crtc->current_transform.transform, &cur);
+ mode_geometry (crtc->mode_info, crtc_info->rotation,
+ &crtc->pending_transform.transform, &pending);
+
+ if (cur.x1 == pending.x1 && cur.x2 == pending.x2 &&
+ cur.y1 == pending.y1 && cur.y2 == pending.y2) {
+ int x = crtc_info->x + cur.x1;
+ int y = crtc_info->y + cur.y1;
+ int w = cur.x2 - cur.x1;
+ int h = cur.y2 - cur.y1;
- /* if it fits, skip it */
- if (x + w <= fb_width && y + h <= fb_height)
- continue;
+ /* if it fits, skip it */
+ if (x + w <= fb_width && y + h <= fb_height)
+ continue;
+ }
crtc->changing = True;
}
s = crtc_disable (crtc);
@@ -2274,6 +2271,38 @@ check_strtod(char *s)
return result;
}
+static void *
+ctm_from_string(const char *str, int *returned_nitems)
+{
+ double ctm[9];
+ long *prop;
+ int i;
+
+ if (sscanf (str, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
+ &ctm[0],&ctm[1],&ctm[2],
+ &ctm[3],&ctm[4],&ctm[5],
+ &ctm[6],&ctm[7],&ctm[8]) != 9)
+ return NULL;
+
+ prop = malloc (2*9*sizeof(prop[0]));
+ if (!prop)
+ return NULL;
+
+ for (i = 0; i < 9; i++) {
+ unsigned long long tmp;
+
+ tmp = fabs (ctm[i]) * (1ULL << 32);
+ if (ctm[i] < 0.0)
+ tmp |= 1ULL << 63;
+
+ prop[i*2+0] = tmp & 0xffffffff;
+ prop[i*2+1] = tmp >> 32;
+ }
+
+ *returned_nitems = 2*9;
+
+ return prop;
+}
static void *
property_values_from_string(const char *str, const Atom type, const int format,
@@ -2462,6 +2491,32 @@ print_guid(const unsigned char *prop)
}
static void
+print_ctm(const unsigned long *prop)
+{
+ printf("\t");
+ for (int i = 0; i < 9; i++)
+ {
+ unsigned long long tmp;
+ double c;
+
+ tmp = prop[2*i+1];
+ tmp <<= 32;
+ tmp |= prop[2*i+0];
+
+ c = (double)(tmp & ~(1ULL << 63)) / (1ULL << 32);
+ if (tmp & (1ULL << 63))
+ c = -c;
+
+ printf("%f", c);
+ if (i == 2 || i == 5)
+ printf("\n\t\t");
+ else if (i != 8)
+ printf(" ");
+ }
+ printf("\n");
+}
+
+static void
print_output_property(const char *atom_name,
int value_format,
Atom value_type,
@@ -2498,6 +2553,12 @@ print_output_property(const char *atom_n
print_guid (prop);
return;
}
+ else if (strcmp (atom_name, "CTM") == 0 && value_format == 32 &&
+ value_type == XA_INTEGER && nitems == 9*2)
+ {
+ print_ctm ((unsigned long *)prop);
+ return;
+ }
for (int k = 0; k < nitems; k++)
{
@@ -3364,6 +3425,7 @@ main (int argc, char **argv)
for (output_prop_t *prop = output->props; prop; prop = prop->next)
{
Atom name = XInternAtom (dpy, prop->name, False);
+ char *atom_name = XGetAtomName (dpy, name);
Atom type;
int format = 0;
unsigned char *data, *malloced_data = NULL;
@@ -3391,8 +3453,12 @@ main (int argc, char **argv)
format = actual_format;
}
- malloced_data = property_values_from_string
- (prop->value, type, actual_format, &nelements);
+ if (strcmp (atom_name, "CTM") == 0 && type == XA_INTEGER && actual_format == 32)
+ malloced_data = ctm_from_string (prop->value, &nelements);
+
+ if (!malloced_data)
+ malloced_data = property_values_from_string (prop->value, type,
+ actual_format, &nelements);
if (malloced_data)
{
Index: xsrc/external/mit/xtrans/dist/Xtrans.c
diff -u xsrc/external/mit/xtrans/dist/Xtrans.c:1.2 xsrc/external/mit/xtrans/dist/Xtrans.c:1.3
--- xsrc/external/mit/xtrans/dist/Xtrans.c:1.2 Mon Jun 19 07:23:39 2023
+++ xsrc/external/mit/xtrans/dist/Xtrans.c Sat Nov 16 08:49:09 2024
@@ -150,7 +150,6 @@ TRANS(SelectTransport) (const char *prot
#ifndef HAVE_STRCASECMP
char protobuf[PROTOBUFSIZE];
#endif
- int i;
prmsg (3,"SelectTransport(%s)\n", protocol);
@@ -163,14 +162,14 @@ TRANS(SelectTransport) (const char *prot
strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
protobuf[PROTOBUFSIZE-1] = '\0';
- for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
+ for (unsigned int i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
if (isupper ((unsigned char)protobuf[i]))
protobuf[i] = tolower ((unsigned char)protobuf[i]);
#endif
/* Look at all of the configured protocols */
- for (i = 0; i < NUMTRANS; i++)
+ for (unsigned int i = 0; i < NUMTRANS; i++)
{
#ifndef HAVE_STRCASECMP
if (!strcmp (protobuf, Xtransports[i].transport->TransName))
@@ -204,9 +203,9 @@ TRANS(ParseAddress) (const char *address
char *mybuf, *tmpptr = NULL;
const char *_protocol = NULL;
- char *_host;
- const char *_port;
+ const char *_host, *_port;
char hostnamebuf[256];
+ char *_host_buf;
int _host_len;
prmsg (3,"ParseAddress(%s)\n", address);
@@ -244,9 +243,10 @@ TRANS(ParseAddress) (const char *address
_protocol = mybuf;
- if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&
- ((mybuf = strrchr (tmpptr,':')) == NULL) )
- {
+ if ((mybuf == NULL) ||
+ ( ((mybuf = strchr (mybuf, '/')) == NULL) &&
+ ((mybuf = strrchr (tmpptr, ':')) == NULL) ) )
+ {
/* address is in a bad format */
*protocol = NULL;
*host = NULL;
@@ -294,7 +294,7 @@ TRANS(ParseAddress) (const char *address
/* Get the host part */
- _host = mybuf;
+ _host = _host_buf = mybuf;
if ((mybuf = strrchr (mybuf,':')) == NULL)
{
@@ -317,10 +317,10 @@ TRANS(ParseAddress) (const char *address
/* hostname in IPv6 [numeric_addr]:0 form? */
else if ( (_host_len > 3) &&
((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0))
- && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) {
+ && (_host_buf[0] == '[') && (_host_buf[_host_len - 1] == ']') ) {
struct sockaddr_in6 sin6;
- *(_host + _host_len - 1) = '\0';
+ _host_buf[_host_len - 1] = '\0';
/* Verify address is valid IPv6 numeric form */
if (inet_pton(AF_INET6, _host + 1, &sin6) == 1) {
@@ -329,7 +329,7 @@ TRANS(ParseAddress) (const char *address
_protocol = "inet6";
} else {
/* It's not, restore it just in case some other code can use it. */
- *(_host + _host_len - 1) = ']';
+ _host_buf[_host_len - 1] = ']';
}
}
#endif
@@ -500,18 +500,19 @@ TRANS(Reopen) (int type, int trans_id, i
XtransConnInfo ciptr = NULL;
Xtransport *thistrans = NULL;
char *save_port;
- int i;
prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port);
/* Determine the transport type */
- for (i = 0; i < NUMTRANS; i++)
+ for (unsigned int i = 0; i < NUMTRANS; i++)
+ {
if (Xtransports[i].transport_id == trans_id)
{
thistrans = Xtransports[i].transport;
break;
}
+ }
if (thistrans == NULL)
{
@@ -603,9 +604,8 @@ TRANS(GetReopenInfo) (XtransConnInfo cip
int *trans_id, int *fd, char **port)
{
- int i;
-
- for (i = 0; i < NUMTRANS; i++)
+ for (unsigned int i = 0; i < NUMTRANS; i++)
+ {
if (Xtransports[i].transport == ciptr->transptr)
{
*trans_id = Xtransports[i].transport_id;
@@ -616,6 +616,7 @@ TRANS(GetReopenInfo) (XtransConnInfo cip
else
return 1;
}
+ }
return 0;
}
@@ -1021,13 +1022,12 @@ complete_network_count (void)
{
int count = 0;
int found_local = 0;
- int i;
/*
* For a complete network, we only need one LOCALCONN transport to work
*/
- for (i = 0; i < NUMTRANS; i++)
+ for (unsigned int i = 0; i < NUMTRANS; i++)
{
if (Xtransports[i].transport->flags & TRANS_ALIAS
|| Xtransports[i].transport->flags & TRANS_NOLISTEN)
@@ -1060,7 +1060,7 @@ receive_listening_fds(const char* port,
return -1;
}
- for (i = 0; i < systemd_listen_fds && *count_ret < NUMTRANS; i++)
+ for (i = 0; i < systemd_listen_fds && *count_ret < (int)NUMTRANS; i++)
{
struct sockaddr_storage a;
int ti;
@@ -1127,8 +1127,8 @@ TRANS(MakeAllCOTSServerListeners) (const
{
char buffer[256]; /* ??? What size ?? */
- XtransConnInfo ciptr, temp_ciptrs[NUMTRANS];
- int status, i, j;
+ XtransConnInfo ciptr, temp_ciptrs[NUMTRANS] = { NULL };
+ int status, j;
#if defined(IPv6) && defined(AF_INET6)
int ipv6_succ = 0;
@@ -1152,7 +1152,7 @@ TRANS(MakeAllCOTSServerListeners) (const
if (receive_listening_fds(port, temp_ciptrs, count_ret) < 0)
return -1;
- for (i = 0; i < NUMTRANS; i++)
+ for (unsigned int i = 0; i < NUMTRANS; i++)
{
Xtransport *trans = Xtransports[i].transport;
unsigned int flags = 0;
@@ -1200,7 +1200,8 @@ TRANS(MakeAllCOTSServerListeners) (const
"MakeAllCOTSServerListeners: server already running\n");
for (j = 0; j < *count_ret; j++)
- TRANS(Close) (temp_ciptrs[j]);
+ if (temp_ciptrs[j] != NULL)
+ TRANS(Close) (temp_ciptrs[j]);
*count_ret = 0;
*ciptrs_ret = NULL;
@@ -1244,7 +1245,7 @@ TRANS(MakeAllCOTSServerListeners) (const
return -1;
}
- for (i = 0; i < *count_ret; i++)
+ for (int i = 0; i < *count_ret; i++)
{
(*ciptrs_ret)[i] = temp_ciptrs[i];
}
@@ -1349,7 +1350,7 @@ int TRANS(GetHostname) (char *buf, int m
uname (&name);
len = strlen (name.nodename);
if (len >= maxlen) len = maxlen - 1;
- strncpy (buf, name.nodename, len);
+ memcpy (buf, name.nodename, len);
buf[len] = '\0';
#else
buf[0] = '\0';
Index: xsrc/external/mit/xtrans/dist/Xtranssock.c
diff -u xsrc/external/mit/xtrans/dist/Xtranssock.c:1.4 xsrc/external/mit/xtrans/dist/Xtranssock.c:1.5
--- xsrc/external/mit/xtrans/dist/Xtranssock.c:1.4 Mon Jun 19 06:44:24 2023
+++ xsrc/external/mit/xtrans/dist/Xtranssock.c Sat Nov 16 08:49:09 2024
@@ -196,7 +196,8 @@ static Sockettrans2dev Sockettrans2devta
static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#endif
-#if defined(TCPCONN) || defined(TRANS_REOPEN)
+#if (defined(TCPCONN) && defined(TRANS_SERVER)) || defined(TRANS_REOPEN) || \
+ !defined(IPv6)
static int
is_numeric (const char *str)
{
@@ -259,7 +260,7 @@ TRANS(SocketSelectFamily) (int first, co
prmsg (3,"SocketSelectFamily(%s)\n", family);
- for (i = first + 1; i < NUMSOCKETFAMILIES;i++)
+ for (i = first + 1; i < (int)NUMSOCKETFAMILIES; i++)
{
if (!strcmp (family, Sockettrans2devtab[i].transname))
return i;
@@ -408,14 +409,22 @@ TRANS(SocketOpen) (int i, int type)
return NULL;
}
- if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
- Sockettrans2devtab[i].protocol)) < 0
+ ciptr->fd = socket(Sockettrans2devtab[i].family, type,
+ Sockettrans2devtab[i].protocol);
+
#ifndef WIN32
#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
- || ciptr->fd >= sysconf(_SC_OPEN_MAX)
+ if (ciptr->fd >= sysconf(_SC_OPEN_MAX))
+ {
+ prmsg (2, "SocketOpen: socket() returned out of range fd %d\n",
+ ciptr->fd);
+ close (ciptr->fd);
+ ciptr->fd = -1;
+ }
#endif
#endif
- ) {
+
+ if (ciptr->fd < 0) {
#ifdef WIN32
errno = WSAGetLastError();
#endif
@@ -732,7 +741,7 @@ static int
set_sun_path(const char *port, const char *upath, char *path, int abstract)
{
struct sockaddr_un s;
- int maxlen = sizeof(s.sun_path) - 1;
+ ssize_t maxlen = sizeof(s.sun_path) - 1;
const char *at = "";
if (!port || !*port || !path)
@@ -748,7 +757,7 @@ set_sun_path(const char *port, const cha
if (*port == '/') /* a full pathname */
upath = "";
- if (strlen(port) + strlen(upath) > maxlen)
+ if ((ssize_t)(strlen(at) + strlen(upath) + strlen(port)) > maxlen)
return -1;
snprintf(path, sizeof(s.sun_path), "%s%s%s", at, upath, port);
return 0;
@@ -778,7 +787,7 @@ TRANS(SocketCreateListener) (XtransConnI
else
retry = 0;
- while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)
+ while (bind (fd, sockname, namelen) < 0)
{
if (errno == EADDRINUSE) {
if (flags & ADDR_IN_USE_ALLOWED)
@@ -1382,6 +1391,11 @@ TRANS(SocketINETConnect) (XtransConnInfo
}
} else {
addrlist = malloc(sizeof(struct addrlist));
+ if (addrlist == NULL) {
+ prmsg (1, "SocketINETConnect() can't allocate memory "
+ "for addrlist: %s\n", strerror(errno));
+ return TRANS_CONNECT_FAILED;
+ }
addrlist->firstaddr = NULL;
}