Skip to contentSkip to conversation

backlight: use system() instead of System()

PATCH New Enrico Weigelt, metux IT consult 2 participants 4 messages Feb 22, 2024 – Feb 23, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/3 sna: stop using obsolete type aliases

The Xserver has been moved to using pixman for all matrix operations, back in 2008, but left some #define's so drivers still compile. Since 1.5 decades have passed now, it's time to fix remaining drivers still using the old name, so we can drop these #define's from the Xserver includes.

---
 src/sna/sna_display.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/sna/sna_display.c +4 -4
index 15df51f6..3ff3d2fe 100644
@@ -208,7 +208,7 @@ struct sna_crtc {
 	bool hwcursor;
 	bool flip_pending;
 
-	struct pict_f_transform cursor_to_fb, fb_to_cursor;
+	struct pixman_f_transform cursor_to_fb, fb_to_cursor;
 
 	RegionRec crtc_damage;
 	uint16_t shadow_bo_width, shadow_bo_height;
@@ -2376,7 +2376,7 @@ static bool use_shadow(struct sna *sna, xf86CrtcPtr crtc)
 {
 	RRTransformPtr transform;
 	PictTransform crtc_to_fb;
-	struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
+	struct pixman_f_transform f_crtc_to_fb, f_fb_to_crtc;
 	unsigned pitch_limit;
 	BoxRec b;
 
@@ -2846,7 +2846,7 @@ affine_is_pixel_exact(const struct pixman_f_transform *t)
 static void sna_crtc_randr(xf86CrtcPtr crtc)
 {
 	struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
-	struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
+	struct pixman_f_transform f_crtc_to_fb, f_fb_to_crtc;
 	PictTransform crtc_to_fb;
 	PictFilterPtr filter;
 	xFixed *params;
@@ -6666,7 +6666,7 @@ sna_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 		if (crtc->transform_in_use) {
 			int xhot = sna->cursor.ref->bits->xhot;
 			int yhot = sna->cursor.ref->bits->yhot;
-			struct pict_f_vector v, hot;
+			struct pixman_f_vector v, hot;
 
 			v.v[0] = x + xhot + .5;
 			v.v[1] = y + yhot + .5;

--
2.39.2

#2 lore raw

PATCH 2/3 sna: use GCPtr instead of GC *

In reply to a message not in the archive

Xserver includes have explicit pointer types for quite all kind of structs (at least those used by drivers), which are used all over the Xserver. Thus it's much cleaner to use those everywhere.

This commit also clears the road to fix a horrible nightmare of hacks just needed to circumvent naming clashes between Xserver and Xlib (affecting all DDXes that are painting on another Xserver): we can simply rename Xserver's own "GC" type to "GCRec" (the usual naming convention here) and so no trouble with Xlib's "GC" type anymore. Once this has landed, we're free to do that without breaking this driver.

---
 src/sna/sna_accel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/sna/sna_accel.c +2 -2
index 89b82afa..90a61ab3 100644
@@ -14300,7 +14300,7 @@ static void
 sna_poly_fill_rect_stippled_n_box__imm(struct sna *sna,
 				       struct kgem_bo *bo,
 				       uint32_t br00, uint32_t br13,
-				       const GC *gc,
+				       const GCPtr gc,
 				       const BoxRec *box,
 				       const DDXPointRec *origin)
 {
@@ -14412,7 +14412,7 @@ sna_poly_fill_rect_stippled_n_box(struct sna *sna,
 				  struct kgem_bo *bo,
 				  struct kgem_bo **tile,
 				  uint32_t br00, uint32_t br13,
-				  const GC *gc,
+				  const GCPtr gc,
 				  const BoxRec *box,
 				  const DDXPointRec *origin)
 {

--
2.39.2

#3 lore raw

PATCH 3/3 backlight: use system() instead of System()

In reply to a message not in the archive

The Xserver's System() function is a special wrapper for calling a program (xkbcomp) as an unprivileged user, when the Xserver is running as suid-root. (which today only needed on a few platforms, eg. Solaris). Therefore it's not suited for being called by arbitrary drivers.

In this specific context it doesn't even much sense, since it's just used for checking whether pkexec command is present at all (and just should be used), while the actual exec'ing of the helper is done directly by fork() and exec() syscalls.

Thus we can safely use standard system() call instead - clearing the road for dropping System() from Xserver's public/driver API.

---
 src/backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/backlight.c +1 -1
index fcbb279f..f416f2a4 100644
@@ -366,7 +366,7 @@ static int __backlight_helper_init(struct backlight *b, char *iface)
 		return 0;
 
 	if ((st.st_mode & (S_IFREG | S_ISUID | S_IXUSR)) != (S_IFREG | S_ISUID | S_IXUSR)) {
-		if (System("pkexec --version"))
+		if (system("pkexec --version"))
 			return 0;
 
 		use_pkexec = 1;

--
2.39.2

#4 lore raw

✗ Fi.CI.BUILD: failure for series starting with [1/3] sna: stop using obsolete type aliases

In reply to a message not in the archive
== Series Details ==

== Series Details ==

Series: series starting with [1/3] sna: stop using obsolete type aliases
URL : https://patchwork.freedesktop.org/series/130259/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/130259/revisions/1/mbox/ not applied
Applying: sna: stop using obsolete type aliases
error: sha1 information is lacking or useless (src/sna/sna_display.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 sna: stop using obsolete type aliases
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced