VirtualBox

Changeset 90860 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 24, 2021 9:41:49 PM (3 years ago)
Author:
vboxsync
Message:

IPRT/log: Adjusted RTLogSetFlushCallback so it doesn't upset clang too badly. bugref:10086

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r90858 r90860  
    12361236RT_EXPORT_SYMBOL(RTLogSetCustomPrefixCallback);
    12371237
    1238 /**
    1239  * Sets the custom prefix callback.
     1238
     1239/**
     1240 * Sets the custom flush callback.
     1241 *
     1242 * This can be handy for special loggers like the per-EMT ones in ring-0,
     1243 * but also for implementing a log viewer in the debugger GUI.
    12401244 *
    12411245 * @returns IPRT status code.
    1242  * @param   pLogger     The logger instance.
    1243  * @param   pfnCallback The callback.
    1244  * @param   pvUser      The user argument for the callback.
    1245  *  */
    1246 RTDECL(int) RTLogSetFlushCallback(PRTLOGGER pLogger, PFNRTLOGFLUSH pfnFlush, PFNRTLOGFLUSH *ppfnOldFlush)
    1247 {
     1246 * @retval  VWRN_ALREADY_EXISTS if it was set to a different flusher.
     1247 * @param   pLogger         The logger instance.
     1248 * @param   pfnFlush        The flush callback.
     1249 */
     1250RTDECL(int) RTLogSetFlushCallback(PRTLOGGER pLogger, PFNRTLOGFLUSH pfnFlush)
     1251{
     1252    int rc;
     1253
    12481254    /*
    12491255     * Resolve defaults.
     
    12611267     * Do the work.
    12621268     */
    1263     rtlogLock(pLoggerInt);
    1264     if (ppfnOldFlush)
    1265         *ppfnOldFlush = pLoggerInt->pfnFlush;
    1266     pLoggerInt->pfnFlush = pfnFlush;
    1267     rtlogUnlock(pLoggerInt);
    1268 
    1269     return VINF_SUCCESS;
     1269    rc = rtlogLock(pLoggerInt);
     1270    if (RT_SUCCESS(rc))
     1271    {
     1272        if (pLoggerInt->pfnFlush && pLoggerInt->pfnFlush != pfnFlush)
     1273            rc = VWRN_ALREADY_EXISTS;
     1274        pLoggerInt->pfnFlush = pfnFlush;
     1275        rtlogUnlock(pLoggerInt);
     1276    }
     1277
     1278    return rc;
    12701279}
    12711280RT_EXPORT_SYMBOL(RTLogSetFlushCallback);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette