Bug 103221 - core/tools/source/fsys/urlobj.cxx:4450: unmaintainable code ?
Summary: core/tools/source/fsys/urlobj.cxx:4450: unmaintainable code ?
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Sandeep Dubey
URL:
Whiteboard: target:5.4.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2016-10-14 18:27 UTC by dcb314
Modified: 2017-02-15 16:16 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dcb314 2016-10-14 18:27:53 UTC
tools/source/fsys/urlobj.cxx:4450:1: error: V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the '&&' operator.

Source code is


        eStyle = eStyle & FSYS_VOS
                 && m_aHost.isPresent()
                 && m_aHost.getLength() > 0 ?
                     FSYS_VOS :
                 hasDosVolume(eStyle)
                 || ((eStyle & FSYS_DOS) != 0
                    && m_aHost.isPresent()
                    && m_aHost.getLength() > 0) ?
                     FSYS_DOS :
                 eStyle & FSYS_UNX
                 && (!m_aHost.isPresent() || m_aHost.getLength() == 0) ?
                     FSYS_UNX :
                     FSysStyle(0);

What a mess ! Nested ternary operators are worth avoiding.

Suggest recode with a clear sequence of if-then-else statements.
Comment 1 Julien Nabet 2016-10-14 18:48:46 UTC
I don't know if we can consider this as a bug since there's no buggy behavior but if interested, you can help to clean up this mess! :-)
(see https://wiki.documentfoundation.org/Development/GetInvolved)
Comment 2 Xisco Faulí 2016-10-26 20:59:51 UTC
moving it to NEW as per comment 1. Besides, adding keyword easyHack.
Comment 3 saurabh kukade 2016-12-27 15:18:29 UTC
I have fixed this issue. Please review here https://gerrit.libreoffice.org/32453
Comment 4 Julien Nabet 2017-01-13 18:07:59 UTC
(In reply to saurabh kukade from comment #3)
> I have fixed this issue. Please review here
> https://gerrit.libreoffice.org/32453

The patch has been commented by several people. Could you give an update or do you want to abandon this one? (in this case, please unassign yourself to make the bugtracker available again).
Comment 5 jani 2017-02-13 07:13:25 UTC
A polite ping, still working on this patch ?
Comment 6 dcb314 2017-02-13 09:36:43 UTC
(In reply to jan iversen from comment #5)
> A polite ping, still working on this patch ?

Not sure if you mean me (dcb) but the patch looks reasonably ok to me.
Comment 7 Julien Nabet 2017-02-13 09:50:36 UTC
(In reply to dcb314 from comment #6)
> (In reply to jan iversen from comment #5)
> > A polite ping, still working on this patch ?
> 
> Not sure if you mean me (dcb) but the patch looks reasonably ok to me.

I suppose Jan's comment was concerning the assignee of this bugtracker, "Sandeep Dubey".
Comment 8 jani 2017-02-13 09:51:49 UTC
(In reply to Julien Nabet from comment #7)
> (In reply to dcb314 from comment #6)
> > (In reply to jan iversen from comment #5)
> > > A polite ping, still working on this patch ?
> > 
> > Not sure if you mean me (dcb) but the patch looks reasonably ok to me.
> 
> I suppose Jan's comment was concerning the assignee of this bugtracker,
> "Sandeep Dubey".

Yes it was, we try to make sure bugs are being worked on, or set back to NEW.
Comment 9 Fakabbir amin 2017-02-15 06:35:07 UTC
(In reply to jani from comment #8)
> (In reply to Julien Nabet from comment #7)
> > (In reply to dcb314 from comment #6)
> > > (In reply to jan iversen from comment #5)
> > > > A polite ping, still working on this patch ?
> > > 
> > > Not sure if you mean me (dcb) but the patch looks reasonably ok to me.
> > 
> > I suppose Jan's comment was concerning the assignee of this bugtracker,
> > "Sandeep Dubey".
> 
> Yes it was, we try to make sure bugs are being worked on, or set back to NEW.

It has been too long since any progress been made. Can I upload patch with with clear sequence of if-else code ?
Comment 10 jani 2017-02-15 06:37:22 UTC
(In reply to Fakabbir amin from comment #9)
> (In reply to jani from comment #8)
> > (In reply to Julien Nabet from comment #7)
> > > (In reply to dcb314 from comment #6)
> > > > (In reply to jan iversen from comment #5)
> > > > > A polite ping, still working on this patch ?
> > > > 
> > > > Not sure if you mean me (dcb) but the patch looks reasonably ok to me.
> > > 
> > > I suppose Jan's comment was concerning the assignee of this bugtracker,
> > > "Sandeep Dubey".
> > 
> > Yes it was, we try to make sure bugs are being worked on, or set back to NEW.
> 
> It has been too long since any progress been made. Can I upload patch with
> with clear sequence of if-else code ?

Patches are always welcome, but in gerrit please.
Comment 11 Commit Notification 2017-02-15 16:11:14 UTC
Fakabbir Amin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2af4221bd1f91b4cef22d6b1867a250e3780f6e3

tdf#103221 recoded clear if-else sequence

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Julien Nabet 2017-02-15 16:16:42 UTC
Let's put this one to FIXED since the commit has been pushed on master sources.