Skip to contentSkip to conversation

drm/radeon: avoid printing NULL strings

PATCH In review Arnd Bergmann 3 participants 5 messages May 15 – May 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: avoid printing NULL strings

From: Arnd Bergmann <[email protected]>

gcc-10 warns about some printf format strings that are used to unconditionally print a NULL string pointer from some call sites:

In function 'evergreen_surface_check',
inlined from 'evergreen_cs_track_validate_stencil' at drivers/gpu/drm/radeon/evergreen_cs.c:592:6, inlined from 'evergreen_cs_track_check' at drivers/gpu/drm/radeon/evergreen_cs.c:995:8:
include/linux/dev_printk.h:156:24: error: '%s' directive argument is null [-Werror=format-overflow=]
156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)

This is harmless here because the kernel prints them as "(null)", but still breaks the build when compiling with -Werror.

Pass empty strings instead to avoid these warnings.

Fixes 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")
---
 drivers/gpu/drm/radeon/evergreen_cs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +3 -3
index daaeae6ba141..550e8f35c7d2 100644
@@ -589,7 +589,7 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)
 		return r;
 	}
 
-	r = evergreen_surface_check(p, &surf, NULL);
+	r = evergreen_surface_check(p, &surf, "");
 	if (r) {
 		/* old userspace doesn't compute proper depth/stencil alignment
 		 * check that alignment against a bigger byte per elements and
@@ -818,7 +818,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p,
 	}
 
 	/* align height */
-	evergreen_surface_check(p, &surf, NULL);
+	evergreen_surface_check(p, &surf, "");
 	surf.nby = ALIGN(surf.nby, surf.halign);
 
 	r = evergreen_surface_check(p, &surf, "texture");
@@ -881,7 +881,7 @@ static int evergreen_cs_track_validate_texture(struct radeon_cs_parser *p,
 				surf.mode = ARRAY_1D_TILED_THIN1;
 			}
 			/* recompute alignment */
-			evergreen_surface_check(p, &surf, NULL);
+			evergreen_surface_check(p, &surf, "");
 			break;
 		case ARRAY_LINEAR_GENERAL:
 		case ARRAY_LINEAR_ALIGNED:
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/1 drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check

'evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.

This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.

Fixes 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")
---
 drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +4 -2
index 3142ef4da7f4..9196f85db9ce 100644
@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,
 	case ARRAY_2D_TILED_THIN1:
 		return evergreen_surface_check_2d(p, surf, prefix);
 	default:
-		dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
-				__func__, __LINE__, prefix, surf->mode);
+		if (prefix) {
+			dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
+					__func__, __LINE__, prefix, surf->mode);
+		}
 		return -EINVAL;
 	}
 	return -EINVAL;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 1/1 drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check

In reply to Arnd Bergmann

'evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.

This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.

Fixes 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")
---
 drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +4 -2
index 3142ef4da7f4..9196f85db9ce 100644
@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,
 	case ARRAY_2D_TILED_THIN1:
 		return evergreen_surface_check_2d(p, surf, prefix);
 	default:
-		dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
-				__func__, __LINE__, prefix, surf->mode);
+		if (prefix) {
+			dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
+					__func__, __LINE__, prefix, surf->mode);
+		}
 		return -EINVAL;
 	}
 	return -EINVAL;
Signature · 1 line
2.43.0
Applied
#4 lore raw

Re: [PATCH] drm/radeon/evergreen_cs: Add missing NULL prefix check in surface check

Applied. Thanks!

Quoted 41 lines · On Mon, May 18, 2026 at 6:29 AM Vitaliy Triang3l Kuzmin <[email protected]> wrote:

'evergreen_surface_check' is called with a NULL warning prefix when handling potentially recoverable issues or just to compute the alignment requirements, and 'evergreen_surface_check' is called again in case of failure (with the correct prefix, as opposed to NULL), therefore, the initial check must not print a warning, because the surface may be accepted successfully after having been corrected, however if it isn't, the final check will print the warning anyway. The surface check functions specific to array modes already implement this behavior, but the 'evergreen_surface_check' function itself doesn't.

This is also supposed to fix the "'%s' directive argument is null [-Werror=format-overflow=]" compiler warning.

Fixes 285484e2d55e ("drm/radeon: add support for evergreen/ni tiling informations v11")
---
  drivers/gpu/drm/radeon/evergreen_cs.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +4 -3
index 3142ef4da7f4..9196f85db9ce 100644
@@ -312,8 +312,10 @@ static int evergreen_surface_check(struct radeon_cs_parser *p,
        case ARRAY_2D_TILED_THIN1:
                return evergreen_surface_check_2d(p, surf, prefix);
        default:
-               dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
-                               __func__, __LINE__, prefix, surf->mode);
+               if (prefix) {
+                       dev_warn(p->dev, "%s:%d %s invalid array mode %d\n",
+                                       __func__, __LINE__, prefix, surf->mode);
+               }
                return -EINVAL;
        }
        return -EINVAL;
--

2.43.0