-
Notifications
You must be signed in to change notification settings - Fork 140
Fix i386 compilation #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix i386 compilation #2396
Conversation
|
SOFCI TEST |
87410f5 to
f021254
Compare
|
wow. This is really bad, we have 3 new error cases with two test runs. https://sof-ci.01.org/linuxpr/PR2396/build4392/devicetest/ @fredoh9 @marc-hb I am afraid we claimed victory too early, the problems with CI targets continue. Gah. |
|
I don't know |
sound/soc/sof/control.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmh, type-casts are evil(TM). Is there any specific reason for this one? It's only to fix the printk() format, right? The calculation, the value would be exactly the same if we just used %d? Maybe just do that then... Or is this because size_t is a different type on 32-bit builds, ARM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be->max is an int, but after arithmetic with sizeof(), it's a "unsigned int" right. so would "%u" as printf syntax solve ths issue without a cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh yes size_t is different.
I tried earlier with a %d but it wouldn't work for x86_64. the %lu fails on 32-bit.
So I settled on a typecast to force the use of size_t, and let the compiler adjust.
If you have a better solution I am all ears, just trying to avoid an error reported upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be->max is an int, but after arithmetic with sizeof(), it's a "unsigned int" right. so would "%u" as printf syntax solve ths issue without a cast?
@kv2019i no, sizeof() returns a size_t, which can be 32 or 64 bits, so that impacts the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cast seems unnecessary, %zd should be enough. Have you tried with %zd only and no cast?
I think we can safely assume size_t has a rank always greater or equal to int.
In user space the following code compiles with both -m32 and -m64 without any warning:
int i = -1;
size_t s = 42;
printf ("%zd", i - s);https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules
Usual arithmetic conversions
3. If the operand that has unsigned integer type has rank greater than or equal to the rank of the type of the other operand, the operand with signed integer type is converted to the type of the operand with unsigned integer type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because you switch to %lu (by accident?). I wrote no cast and %zu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see e1cc344, didn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that e1cc344 has %lu and not the %zu that I suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's %zu alright e1cc344#diff-6782c454986b1c6b9d4916315dd9dec7R391
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I was misled by the error message in topology.c which you hadn't changed yet.
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, good to have the i386 build in travis. See comments inline...
sound/soc/sof/control.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be->max is an int, but after arithmetic with sizeof(), it's a "unsigned int" right. so would "%u" as printf syntax solve ths issue without a cast?
58f779e to
e1cc344
Compare
fix compilation warning in i386 mode.
sound/soc/sof/control.c: In function ‘snd_sof_bytes_ext_volatile_get’:
sound/soc/sof/control.c:388:35: warning: format ‘%lu’ expects argument
of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’
[-Wformat=]
388 | dev_err_ratelimited(scomp->dev, "error: user data size %d
exceeds max size %lu.\n",
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
e1cc344 to
2508038
Compare
The mix of integer and size_t generates different results in 32- and 64 bit mode, cast to size_t and use %zu format. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
@lyakh if you have a better solution without the evil casts that's fine, please provide it as a follow-up |
marc-hb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No cast + %zu does work with both i386 and x86_64, I just tested it locally at last.
However it requires not just one line changes but 5: four in control.c and one in topology.c
I search travis and found the two builds where you tried %zu and no cast. Github inconveniently hides them, maybe because it doesn't support force pushes:
https://travis-ci.org/github/thesofproject/linux/builds/722150716
https://travis-ci.org/github/thesofproject/linux/builds/722132973
None of these failed to compile no cast + %zu because.. they failed earlier, on topology.c!!
UPDATE: and now I just see you merged the spurious cast in 5 places... too bad.
sound/soc/sof/control.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I was misled by the error message in topology.c which you hadn't changed yet.
|
Linux will apparently stop supporting 32bits soon https://lwn.net/Articles/829733/ :-D |
Not making a subscription yet, but does that say only 32-bit Intel? 32-bit platforms are still interesting in the ARM world... |
You should :-) Available for free in 1 week. The slides are already available:
This page and discussions are actually mainly about Linux, ARM and the next decades. Not everyone agrees but the least disagreement seems to be about Linux slowly but surely becoming a 64bit OS. |
|
Same player shoots again in #2413 |
Two recent patches (not yet upstream) broke 32-bit compilation.
@RDharageswari and @lyakh FYI.