! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Compile error in Git: Warning treated as Errors when compiling under Fedora 29
Status:
RESOLVED: FIXED
Product:
Xfdesktop
Component:
General

Comments

Description Ali Akcaagac 2019-01-12 10:57:51 CET
Created attachment 8237 
part of the output

Please have a look at the attachment.

It looks like some of the used functions have been deprecated and thus lead to warnings being treated as errors.
Comment 1 Andre Miranda editbugs 2019-01-13 15:50:14 CET
Hi Ali, I just pushed a couple of commits taking care of deprecated functions, please try again.
Other than that, which parameters are you passing to configure? I only know of --enable-debug=full that will error on deprecated functions.
Comment 2 Ali Akcaagac 2019-01-13 19:52:29 CET
Still getting one warning which gets treated as error:

make[3]: Entering directory '/root/rpmbuild/BUILD/xfdesktop-4.13.2/settings'
  CC       xfdesktop_settings-main.o
main.c: In function 'cb_xfdesktop_icon_orientation_changed':
main.c:1750:29: error: format not a string literal and no format arguments [-Werror=format-security]
                             NULL, question))
                             ^~~~
cc1: some warnings being treated as errors
make[3]: *** [Makefile:619: xfdesktop_settings-main.o] Error 1
make[3]: Leaving directory '/root/rpmbuild/BUILD/xfdesktop-4.13.2/settings'
make[2]: *** [Makefile:490: all] Error 2
make[1]: *** [Makefile:578: all-recursive] Error 1
make: *** [Makefile:489: all] Error 2

Looks like Fedora 29 has add strict build rules to rpmbuild packages. Normal compile works, but using fedora specific compile flags (as rpmbuild does) leads to these strict checks. Must be something new they changed.
Comment 3 Ali Akcaagac 2019-01-13 20:01:51 CET
According the API from libxfce4ui, there should be a primary_format for the printf style format as 5th argument. Though after the NULL (4th argument) the 5th argument shows to another string.

I modified it that way:

    if(!xfce_dialog_confirm(window, "view-sort-ascending", _("Arrange icons"),
                            NULL, "%s", question))
    {

Even if you pass a NUKK as 4th argument, the 5th still has to be a primary format:

 * xfce_dialog_confirm:
 * @parent         : (allow-none): transient parent of the dialog, or %NULL.
 * @stock_id       : the stock name of the confirm button, for example #GTK_STOCK_YES or #GTK_STOCK_CLEAR.
 * @confirm_label  : (allow-none): if non-%NULL, this text is used on the confirm button together with the @stock_id icon.
 * @secondary_text : (allow-none): secondary text in the dialog.
 * @primary_format : (allow-none): the printf()-style format for the dialog question.
 * @...            : (allow-none): argument list for the @primary_format.

There is another call of this kind in the src/windowlist.c file of xfdesktop line 86, which has 6 arguments of which the 5th argument is a primary format.

Can you confirm or verify, if my investigation makes some sense ?
Comment 4 Andre Miranda editbugs 2019-01-13 21:49:41 CET
Please try it now (I know, wrong bug number in commit message):
https://git.xfce.org/xfce/xfdesktop/commit/?id=623613a4e15fab968de1e95b12259b028f636cd1
Comment 5 Ali Akcaagac 2019-01-13 22:19:49 CET
Sorry, same issue!

"" is not a leggit formating argument.

I think the compiler wants something like "%s" or "%d" or one of the other valid formating arguments after the parameter for string.

e.g.

from the API I understand it as this

... "the string you have chosen is this: %s", string

So the "NULL" is ok there because it refers to an empty string literal!

But the "question" string has to be put inside a formating argument, so the compiler stops complaining.

I just changed the code again to the idea that I gave above in comment #3
Comment 6 Andre Miranda editbugs 2019-01-13 22:30:47 CET
I think that API sucks, really. Here are my results:

"%s", NULL, question -> just "%s"
"", question -> question's text in bold
"%s", question -> question's text in bold and a "%s" below it

I'm using gcc 8.2.1 and don't get any warning complaining about the printf format.
Comment 7 Ali Akcaagac 2019-01-13 22:54:00 CET
Same gcc version here.

But I think I have to be more specific here.

What I do is this:

I download the git version of xfdesktop
I then run make dist and generate a tar release file from it
I then use that file together with Fedora 29 *.spec file (from git) to recompile said generated tar release using rpm-build and the spec file

So as a result the build fails because Fedora put some strict checking in one of their *-srpm-macros or maybe in "redhat-rpm-config" (packages) that are mandatory to build rpm packages from sources.

So anyways: Once you release an updated version of xfdesktop, which then might get build for Fedora 29 after some hours, then it may end up receiving the same build failure as I mentioned here.

And no!

I tried "%s", question... This doesn't work because the changed "" to "%s" is not the correct order within the API

the 4th argument has to be a string literal and not a formating argument. So by changing NULL to "" you changed a NULL string to an empty string "".

Both versions might be suitable. Though I would still go for NULL

But the question argument (and thats why the waring is valid after all) is not in the 6th argument but rather in the 5th argument. Therefore the compiler complains because "question" can never be print (it may work from the API) because the 5th argument has to be a formating argument and the 6th argument has to be "question". So "question" from 6th argument will then be put inside the formating argument of the 5th argument... making 5th argument become "question".

If you grep in other sources from Xfce Git, then you see other programs been using the same function and API calls. Though they still have the 5th argument contain some sort of either "formating argument" or "string literal PLUS formatting argument"

so these would be vald 4th arguments

1)

NULL, "%s", question

2)

NULL, "yo, this is the question %s", question

At least it's how I understand it
Comment 8 Ali Akcaagac 2019-01-16 11:45:19 CET
Created attachment 8245 
Temporary workaround for compile warnings!

Unfortunately I hit the sack again with the same issue during full compile of Xfce4 from Git.

This time it was a clean workenvironment and everything has cleanly rebuild with only this exception.

Even if this patch might not be the best solution, this at least bypasses the warning I get.

Leaving it here for temporary solution, until a better approach is found.
Comment 9 Git Bot editbugs 2019-01-20 22:32:09 CET
Andre Miranda referenced this bugreport in commit de7f6854ebb97de56500082cf5e437a07f360e68

Properly fix compile warning (Bug #15034)

https://git.xfce.org/xfce/xfdesktop/commit?id=de7f6854ebb97de56500082cf5e437a07f360e68
Comment 10 Andre Miranda editbugs 2019-01-20 22:33:50 CET
I think this is *the* correct way of using that function.
Thanks for reporting and the patch!

Bug #15034

Reported by:
Ali Akcaagac
Reported on: 2019-01-12
Last modified on: 2019-01-20

People

Assignee:
Eric Koegel
CC List:
1 user

Version

Version:
Unspecified

Attachments

part of the output (2.75 KB, text/plain)
2019-01-12 10:57 CET , Ali Akcaagac
no flags
Temporary workaround for compile warnings! (545 bytes, patch)
2019-01-16 11:45 CET , Ali Akcaagac
no flags

Additional information