Skip to contentSkip to conversation

drm/i915: Disable -Wtautological-constant-out-of-range-compare

PATCH Superseded Nathan Chancellor 5 participants 14 messages Feb 11, 2020 – Feb 13, 2020

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

PATCH 1/1 drm/i915: Disable -Wtautological-constant-out-of-range-compare

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it. -Wtautological-compare on a whole has good warnings but this one is not really relevant for the kernel because of all of the different configurations that are used to build the kernel. When -Wtautological-compare is enabled for the kernel, this option will remain disabled so do that for i915 now.

---
 drivers/gpu/drm/i915/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/Makefile +1 -0
index 38df01c23176..55dbcca179c7 100644
@@ -21,6 +21,7 @@ subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
 subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
 subdir-ccflags-y += $(call cc-disable-warning, sometimes-uninitialized)
 subdir-ccflags-y += $(call cc-disable-warning, initializer-overrides)
+subdir-ccflags-y += $(call cc-disable-warning, tautological-constant-out-of-range-compare)
 subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
 
 # Fine grained warnings disable
Signature · 6 lines
2.25.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: Disable -Wtautological-constant-out-of-range-compare

== Series Details ==

== Series Details ==

Series: drm/i915: Disable -Wtautological-constant-out-of-range-compare
URL : https://patchwork.freedesktop.org/series/73271/
State : failure

== Summary ==

Applying: drm/i915: Disable -Wtautological-constant-out-of-range-compare
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/Makefile).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 drm/i915: Disable -Wtautological-constant-out-of-range-compare 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".

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

PATCH v2 1/1 drm/i915: Disable -Wtautological-constant-out-of-range-compare

In reply to Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it. -Wtautological-compare on a whole has good warnings but this one is not really relevant for the kernel because of all of the different configurations that are used to build the kernel. When -Wtautological-compare is enabled for the kernel, this option will remain disabled so do that for i915 now.

---

v1 -> v2: https://lore.kernel.org/lkml/[email protected]/

* Fix patch application due to basing on a local tree that had -Wuninitialized turned on. Can confirm that patch applies on latest -next now.

 drivers/gpu/drm/i915/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/Makefile +1 -0
index b8c5f8934dbd..159355eb43a9 100644
@@ -22,6 +22,7 @@ subdir-ccflags-y += $(call cc-disable-warning, sign-compare)
 subdir-ccflags-y += $(call cc-disable-warning, sometimes-uninitialized)
 subdir-ccflags-y += $(call cc-disable-warning, initializer-overrides)
 subdir-ccflags-y += $(call cc-disable-warning, uninitialized)
+subdir-ccflags-y += $(call cc-disable-warning, tautological-constant-out-of-range-compare)
 subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
 
 # Fine grained warnings disable
Signature · 1 line
2.25.0
#3 lore raw
Quoted 10 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Quoted 2 lines

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 11 lines · Michel Dänzer
Quoted 10 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Quoted 7 lines
Quoted 2 lines

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX? clang does not warn on a 32-bit x86 build from what I remember. Honestly, my understanding of overflow is pretty shoddy, this is mostly based on what I have heard from others.

I sent a patch trying to remove that check but had it rejected:

https://lore.kernel.org/lkml/[email protected]/

Cheers,
Nathan
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

should silence the warning.

Either of these should be better than completely disabling the warning for the whole file.

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 36 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Quoted 6 lines

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

should silence the warning.

I do like this one better than the former.

Quoted 4 lines

Either of these should be better than completely disabling the warning for the whole file.

Normally, I would agree but I am currently planning to leave -Wtautological-constant-out-of-range-compare disabled when I turn on -Wtautological-compare for the whole kernel because there are plenty of locations in the kernel where these kind of checks depend on various kernel configuration options and the general attitude of kernel developers is that this particular warning is not really helpful for that reason.

I'll see if there is a general consensus before moving further since I know i915 turns on a bunch of extra warnings from the rest of the kernel (hence why we are in this situation).

Cheers,
Nathan

#7 lore raw
Quoted 37 lines · Nathan Chancellor
Quoted 36 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Quoted 8 lines
Quoted 6 lines

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#8 lore raw
Quoted 43 lines · Michel Dänzer
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

I like this better than the UINT_MAX == ULONG_MAX comparison because that creates a dependency on the type of remain.

Then again, a sufficiently clever compiler could see through the cast, and flag the warning anyway...

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw
Quoted 52 lines · Jani Nikula
Quoted 43 lines · Michel Dänzer
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

Quoted 5 lines

I like this better than the UINT_MAX == ULONG_MAX comparison because that creates a dependency on the type of remain.

Then again, a sufficiently clever compiler could see through the cast, and flag the warning anyway...

Would you prefer a patch that adds that cast rather than silencing the warning outright? It does appear to work for clang.

Cheers,
Nathan
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#10 lore raw
Quoted 53 lines · Nathan Chancellor
Quoted 52 lines · Jani Nikula
Quoted 50 lines · Michel Dänzer
Quoted 37 lines · Nathan Chancellor
Quoted 36 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
	if (unlikely(remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

#endif

Quoted 8 lines
Quoted 6 lines

Or if that can't be used for some reason, something like

	if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
		return -EINVAL;

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

Quoted 8 lines
Quoted 5 lines

I like this better than the UINT_MAX == ULONG_MAX comparison because that creates a dependency on the type of remain.

Then again, a sufficiently clever compiler could see through the cast, and flag the warning anyway...

Would you prefer a patch that adds that cast rather than silencing the warning outright? It does appear to work for clang.

I'd take the cast.

If that fails for whatever reason, per-file

CFLAGS_gem/i915_gem_execbuffer.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare)

over subdir-ccflags-y would be preferrable I think.

BR,
Jani.

Quoted 3 lines

Cheers,
Nathan

Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#11 lore raw
In reply to Michel Dänzer
Quoted 44 lines · Michel Dänzer
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
if (unlikely(remain > N_RELOC(ULONG_MAX)))
return -EINVAL;
#endif

Or if that can't be used for some reason, something like

if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
return -EINVAL;

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

The warning is pointing out that the conditional is always false, which is correct on 64b. The check is only active for 32b.
https://godbolt.org/z/oQrgT_
The cast silences the warning for 64b. (Note that GCC and Clang also generate precisely the same instruction sequences in my example, just GCC doesn't warn on such tautologies).

Signature · 2 lines
Thanks,
~Nick Desaulniers
#12 lore raw
Quoted 53 lines · Nick Desaulniers
Quoted 44 lines · Michel Dänzer
Quoted 42 lines · Nathan Chancellor
Quoted 41 lines · Michel Dänzer
Quoted 15 lines · Nathan Chancellor
Quoted 14 lines · Michel Dänzer
Quoted 12 lines · Nathan Chancellor

A recent commit in clang added -Wtautological-compare to -Wall, which is enabled for i915 so we see the following warning:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare]
if (unlikely(remain > N_RELOC(ULONG_MAX)))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

This warning only happens on x86_64 but that check is relevant for 32-bit x86 so we cannot remove it.

Quoted 8 lines
Quoted 4 lines

That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value in both cases, and remain is a 32-bit value in both cases. How can it be larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)?

Hi Michel,

Can't this condition be true when UINT_MAX == ULONG_MAX?

Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit.

Anyway, this suggests a possible better solution:

#if UINT_MAX == ULONG_MAX
if (unlikely(remain > N_RELOC(ULONG_MAX)))
return -EINVAL;
#endif

Or if that can't be used for some reason, something like

if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
return -EINVAL;

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

should silence the warning.

I do like this one better than the former.

FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return.

Quoted 6 lines

The warning is pointing out that the conditional is always false, which is correct on 64b. The check is only active for 32b.
https://godbolt.org/z/oQrgT_
The cast silences the warning for 64b. (Note that GCC and Clang also generate precisely the same instruction sequences in my example, just GCC doesn't warn on such tautologies).

Thanks for confirming! I'll send a patch to add the cast later tonight.

Cheers,
Nathan
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#13 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Disable -Wtautological-constant-out-of-range-compare (rev2)

In reply to Nathan Chancellor
== Series Details ==

== Series Details ==

Series: drm/i915: Disable -Wtautological-constant-out-of-range-compare (rev2)
URL : https://patchwork.freedesktop.org/series/73271/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7905 -> Patchwork_16515
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_16515 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_16515, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_16515:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live_blt:
- fi-hsw-4770r: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7905/fi-hsw-4770r/igt@i915_selftest@live_blt.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/fi-hsw-4770r/igt@i915_selftest@live_blt.html

* igt@i915_selftest@live_objects:
- fi-bwr-2160: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7905/fi-bwr-2160/igt@i915_selftest@live_objects.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/fi-bwr-2160/igt@i915_selftest@live_objects.html

Known issues
------------

Here are the changes found in Patchwork_16515 that come from known issues:

### IGT changes ###

#### Possible fixes ####

* igt@gem_close_race@basic-threads:
- fi-hsw-peppy: [INCOMPLETE][5] ([i915#694] / [i915#816]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7905/fi-hsw-peppy/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/fi-hsw-peppy/igt@[email protected]

* igt@i915_selftest@live_gem_contexts:
- fi-cfl-8700k: [INCOMPLETE][7] ([i915#424]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7905/fi-cfl-8700k/igt@i915_selftest@live_gem_contexts.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/fi-cfl-8700k/igt@i915_selftest@live_gem_contexts.html

[i915#424]: https://gitlab.freedesktop.org/drm/intel/issues/424
[i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694
[i915#816]: https://gitlab.freedesktop.org/drm/intel/issues/816

Participating hosts (46 -> 40)
------------------------------

Additional (4): fi-skl-lmem fi-glk-dsi fi-snb-2520m fi-kbl-r
Missing (10): fi-ilk-m540 fi-bsw-n3050 fi-byt-j1900 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-gdg-551 fi-blb-e6850 fi-byt-clapper fi-bsw-nick

Build changes
-------------

* CI: CI-20190529 -> None
* Linux: CI_DRM_7905 -> Patchwork_16515

CI-20190529: 20190529
CI_DRM_7905: db98da3dd757a19dbaaeaef8640276fe7be2fc4e @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5433: 6a96c17f3a1b4e1f90b1a0b0ce42a7219875d1a4 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_16515: 2b06b9a9a6d6785235ca559832db83a0e69928ff @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

2b06b9a9a6d6 drm/i915: Disable -Wtautological-constant-out-of-range-compare

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16515/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx