Bug 49602 - Remove deprecated OSL Profile functionality
Summary: Remove deprecated OSL Profile functionality
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: reviewed:2022
Keywords: difficultyInteresting, easyHack, skillCpp, topicCleanup
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2012-05-07 12:55 UTC by Sergey
Modified: 2024-03-05 07:14 UTC (History)
5 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 Sergey 2012-05-07 12:55:45 UTC
Seems the only user of it is sal/rtl/source/bootstrap.cxx

it could easily be replaced with something like:

oslProfile profile = osl_openProfile(strProfileName.pData, Options);
if( ! profile )
        throw std::exception();

sal_Char aBuf[1024];
rtl::OString ret= osl_readProfileString( profile, rSection.getStr(), rEntry.getStr(), aBuf, sizeof( aBuf ), rDefault.getStr() ) ? rtl::OString( aBuf ) : rtl::OString();

osl_closeProfile(profile);

return ret;

and then deleted from codebase.
Comment 1 tommy27 2013-08-18 15:35:43 UTC
is this code cleanup still actual?
Comment 2 Stephan Bergmann 2013-10-16 07:02:56 UTC
(In reply to comment #0)
> Seems the only user of it is sal/rtl/source/bootstrap.cxx
> 
> it could easily be replaced with something like:
> 
> oslProfile profile = osl_openProfile(strProfileName.pData, Options);
> if( ! profile )
>         throw std::exception();
> 
> sal_Char aBuf[1024];
> rtl::OString ret= osl_readProfileString( profile, rSection.getStr(),
> rEntry.getStr(), aBuf, sizeof( aBuf ), rDefault.getStr() ) ? rtl::OString(
> aBuf ) : rtl::OString();
> 
> osl_closeProfile(profile);
> 
> return ret;

Given the comment preceding the (only) use of osl::Profile in sal/rtl/bootstrap.cxx,

  // Going through osl::Profile, this code erroneously
  // does not recursively expand macros in the resulting
  // replacement text (and if it did, it would fail to
  // detect cycles that pass through here):

it does not make much sense to merely unwrap that code from using the C++ osl/profile.hxx wrapper to using the underlying C osl/profile.h functionality.

Also note that this is part of the stable URE interface, so cannot be modified arbitrarily (but can arguably be removed in an incompatible release, as it is deprecated for a long time and should effectively be unused by client code).

So, a useful approach could be:

* Adapt sal/rtl/bootstrap.cxx to no longer use the OSL Profile functionality, and in doing so fix the bug described in the comment above.

* In a commit with "[API CHANGE]" in the commit message, remove the include/osl/profile.hxx wrapper.

* In the same or a subsequent "[API CHANGE]" commit, also remove include/sal/profile.h and replace the implementation with stubs in sal/osl/all/compat.cxx (which are necessary as the corresponding symbols could not be removed from sal/util/sal.map without changing the sal SONAME, which we do not want to do).

* Document the incompatible changes in the "API Changes" section of the relevant <https://wiki.documentfoundation.org/ReleaseNotes>.
Comment 3 QA Administrators 2015-04-01 14:42:25 UTC Comment hidden (noise)
Comment 4 Sergey 2015-09-13 17:14:28 UTC
the issue is still present in the latest GIT
Comment 5 Robinson Tryon (qubit) 2015-12-14 05:01:16 UTC Comment hidden (noise)
Comment 6 Robinson Tryon (qubit) 2016-02-18 14:52:25 UTC Comment hidden (noise)
Comment 7 jani 2016-05-29 08:04:03 UTC
A polite ping, still working on this issue?
Comment 8 jani 2016-06-29 05:52:34 UTC
Unassigning due to lack of work.
Comment 9 Hossein 2022-11-24 17:01:30 UTC
Re-evaluating the EasyHack in 2022

This enhancement is still relevant. One should read comment 2 and follow the steps written by Stephan.
Comment 10 seturajmatroja 2024-02-26 02:06:23 UTC
In order to discard the use of deprecated osl::profile and fix the bug mentioned in the comments, do I have to use expandmacros function?
Comment 11 Stephan Bergmann 2024-02-26 07:26:45 UTC
(In reply to seturajmatroja from comment #10)
> In order to discard the use of deprecated osl::profile and fix the bug
> mentioned in the comments, do I have to use expandmacros function?

yes, some recursive use of that macro expansion functionality, more or less
Comment 12 seturajmatroja 2024-03-01 21:49:27 UTC
Are there any previous api changes regarding osl::profile so I can refer them?
Also there is a recursive expandmacros function in the file
Comment 13 Stephan Bergmann 2024-03-03 08:24:23 UTC
(In reply to seturajmatroja from comment #12)
> Are there any previous api changes regarding osl::profile so I can refer
> them?

no, none that I'm aware of

> Also there is a recursive expandmacros function in the file

yes, and it might be part of the fix here, but that needs looking into (which is the easy hack task to be done here :)  that's why I wrote "more or less"
Comment 14 seturajmatroja 2024-03-04 22:45:50 UTC
Does it even reach that point?
As when I tried to run it in full debug mode and added breakpoints to the profile , it never hit that line.
Comment 15 Stephan Bergmann 2024-03-05 07:14:15 UTC
(In reply to seturajmatroja from comment #14)
> Does it even reach that point?

The relevant code in expandMacros would be reached for a reference of the form

> ${<absolute-ini-file-URI>:<section>:<key>}

which is likely not encountered in a typical LO installation set.  (So you would likely set up some test code for it.  There already is e.g. sal/qa/rtl/bootstrap/expand.cxx.)


Caveat:  The existing rtl/bootstrap code just effectively ignores "[section]" markers in the ini-files it processes.  It uniformly consumes all key=value pairs regardless of what sections, if any, they are in.  (It nominally requires that bootstrap variables are in "[bootstrap]" sections, but does not enforce that.  And, for backwards compatibility, we should likely continue with this behavior.)  So there would be a problem how to treat the <section> part in the above reference, if we were to change the processing code from osl/profile to existing rtl/bootsrap functionality.  The change proposed here might or might not be such a bright idea after all, and might or might not actually be an easy hack (though it already has the high category "interesting", for a reason).