switch (action)
PRBool valueChanged = PR_FALSE; if (set_default)
PrefResult pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction action){    PrefHashEntry* pref;    PrefResult result = PREF_OK;    if (!gHashTable.ops)        return PREF_NOT_INITIALIZED;        pref = NS_STATIC_CAST(PrefHashEntry*, PL_DHashTableOperate(&gHashTable, key, PL_DHASH_ADD));    if (!pref)        return PREF_OUT_OF_MEMORY;    // new entry, better intialize    if (!pref->key) {                // initialize the pref entry        pref->flags = type;        pref->key = ArenaStrDup(key, &gPrefNameArena);        pref->defaultPref.intVal = 0;        pref->userPref.intVal = 0;                /* ugly hack -- define it to a default that no pref will ever           default to this should really get fixed right by some out           of band data        */        if (pref->flags & PREF_BOOL)            pref->defaultPref.boolVal = (PRBool) BOGUS_DEFAULT_BOOL_PREF_VALUE;        if (pref->flags & PREF_INT)            pref->defaultPref.intVal = (PRInt32) BOGUS_DEFAULT_INT_PREF_VALUE;    }    else if ((((PrefType)(pref->flags)) & PREF_VALUETYPE_MASK) !=                 (type & PREF_VALUETYPE_MASK))    {        NS_WARNING(nsPrintfCString(192, "Trying to set pref %s to with the wrong type!", key).get());        return PREF_TYPE_CHANGE_ERR;    }    switch (action)    {        case PREF_SETDEFAULT:        case PREF_SETCONFIG:            if (!PREF_IS_LOCKED(pref))            {       /* ?? change of semantics? */                if (pref_ValueChanged(pref->defaultPref, value, type))                {                    pref_SetValue(&pref->defaultPref, value, type);                    if (!PREF_HAS_USER_VALUE(pref))                        result = PREF_VALUECHANGED;                }            }            if (action == PREF_SETCONFIG)                pref->flags |= PREF_CONFIG;            break;          case PREF_SETUSER:            /* If setting to the default value, then un-set the user value.               Otherwise, set the user value only if it has changed */            if ( !pref_ValueChanged(pref->defaultPref, value, type) )            {                if (PREF_HAS_USER_VALUE(pref))                {                    pref->flags &= ~PREF_USERSET;                    if (!PREF_IS_LOCKED(pref))                        result = PREF_VALUECHANGED;                }            }            else if ( !PREF_HAS_USER_VALUE(pref) ||                       pref_ValueChanged(pref->userPref, value, type) )            {                       pref_SetValue(&pref->userPref, value, type);                pref->flags |= PREF_USERSET;                if (!PREF_IS_LOCKED(pref))                    result = PREF_VALUECHANGED;            }            break;                    case PREF_LOCK:            if (pref_ValueChanged(pref->defaultPref, value, type))            {                pref_SetValue(&pref->defaultPref, value, type);                result = PREF_VALUECHANGED;            }            else if (!PREF_IS_LOCKED(pref))            {                result = PREF_VALUECHANGED;            }            pref->flags |= PREF_LOCKED;            gIsAnyPrefLocked = PR_TRUE;            break;    }    if (result == PREF_VALUECHANGED) {        gDirty = PR_TRUE;                if (gCallbacksEnabled) {            PrefResult result2 = pref_DoCallback(key);            if (result2 < 0)                result = result2;        }#ifdef MOZ_PROFILESHARING        if (gSharedPrefHandler)            gSharedPrefHandler->OnPrefChanged(action, pref, value);#endif    }    return result;}