Changeset 14666


Ignore:
Timestamp:
Jan 7, 2016, 7:20:14 PM (5 years ago)
Author:
mikedld
Message:

Use TR_BAD_SIZE instead of -1 in tr_quark_new() calls

Extend quark test to improve branch coverage.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r14241 r14666  
    7676    const gboolean val = gtk_toggle_action_get_active (action);
    7777
    78     gtr_core_set_pref_bool (myCore, tr_quark_new(key,-1), val);
     78    gtr_core_set_pref_bool (myCore, tr_quark_new(key, TR_BAD_SIZE), val);
    7979}
    8080
     
    232232    for (i = 0, n = G_N_ELEMENTS (pref_toggle_entries); i < n; ++i)
    233233        pref_toggle_entries[i].is_active =
    234             gtr_pref_flag_get (tr_quark_new (pref_toggle_entries[i].name, -1));
     234            gtr_pref_flag_get (tr_quark_new (pref_toggle_entries[i].name, TR_BAD_SIZE));
    235235
    236236    gtk_action_group_add_toggle_actions (action_group,
  • trunk/gtk/open-dialog.c

    r14587 r14666  
    4040      const char * val;
    4141      g_snprintf (key, sizeof (key), "recent-download-dir-%d", i+1);
    42       if ((val = gtr_pref_string_get (tr_quark_new(key,-1))))
     42      if ((val = gtr_pref_string_get (tr_quark_new(key, TR_BAD_SIZE))))
    4343        list = g_slist_append (list, (void*)val);
    4444    }
     
    7474      char key[64];
    7575      g_snprintf (key, sizeof (key), "recent-download-dir-%d", i + 1);
    76       gtr_pref_string_set (tr_quark_new(key,-1), l->data);
     76      gtr_pref_string_set (tr_quark_new(key, TR_BAD_SIZE), l->data);
    7777    }
    7878  gtr_pref_save (gtr_core_session (core));
  • trunk/libtransmission/peer-mgr.c

    r14650 r14666  
    20392039
    20402040              if (peer_id != NULL)
    2041                 client = tr_quark_new (tr_clientForId (buf, sizeof (buf), peer_id), -1);
     2041                client = tr_quark_new (tr_clientForId (buf, sizeof (buf), peer_id), TR_BAD_SIZE);
    20422042              else
    20432043                client = TR_KEY_NONE;
  • trunk/libtransmission/peer-msgs.c

    r14664 r14666  
    931931
    932932    if (!version_quark)
    933       version_quark = tr_quark_new (TR_NAME " " USERAGENT_PREFIX, -1);
     933      version_quark = tr_quark_new (TR_NAME " " USERAGENT_PREFIX, TR_BAD_SIZE);
    934934
    935935    dbgmsg (msgs, "sending an ltep handshake");
  • trunk/libtransmission/quark-test.c

    r14241 r14666  
    1818{
    1919  int i;
     20  tr_quark q1, q2;
    2021
    2122  for (i=0; i<TR_N_KEYS; i++)
     
    4243    }
    4344
     45  const tr_quark q = tr_quark_new (NULL, TR_BAD_SIZE);
     46  check_int_eq (TR_KEY_NONE, q);
     47  check_streq ("", tr_quark_get_string (q, NULL));
     48
    4449  return 0;
    4550}
  • trunk/libtransmission/quark.c

    r14428 r14666  
    481481  if (str == NULL)
    482482    len = 0;
    483   else if (len == (size_t)-1)
     483  else if (len == TR_BAD_SIZE)
    484484    len = strlen (str);
    485485
  • trunk/libtransmission/session.c

    r14649 r14666  
    25282528                {
    25292529                  ++n;
    2530                   tr_variantDictAddStr (lookup, tr_quark_new(inf.hashString,-1), path);
     2530                  tr_variantDictAddStr (lookup, tr_quark_new(inf.hashString, TR_BAD_SIZE), path);
    25312531                }
    25322532              tr_free (path);
     
    25492549  if (!session->metainfoLookup)
    25502550    metainfoLookupInit ((tr_session*)session);
    2551   tr_variantDictFindStr (session->metainfoLookup, tr_quark_new(hashString,-1), &filename, NULL);
     2551  tr_variantDictFindStr (session->metainfoLookup, tr_quark_new(hashString, TR_BAD_SIZE), &filename, NULL);
    25522552
    25532553  return filename;
     
    25642564   * lookup table hasn't been built yet */
    25652565  if (session->metainfoLookup)
    2566     tr_variantDictAddStr (session->metainfoLookup, tr_quark_new(hashString,-1), filename);
     2566    tr_variantDictAddStr (session->metainfoLookup, tr_quark_new(hashString, TR_BAD_SIZE), filename);
    25672567}
    25682568
  • trunk/libtransmission/variant-test.c

    r14644 r14666  
    514514  const char * end;
    515515  size_t strLen;
    516   const tr_quark key_bool = tr_quark_new ("this-is-a-bool", -1);
    517   const tr_quark key_real = tr_quark_new ("this-is-a-real", -1);
    518   const tr_quark key_int  = tr_quark_new ("this-is-an-int", -1);
    519   const tr_quark key_str  = tr_quark_new ("this-is-a-string", -1);
     516  const tr_quark key_bool = tr_quark_new ("this-is-a-bool", TR_BAD_SIZE);
     517  const tr_quark key_real = tr_quark_new ("this-is-a-real", TR_BAD_SIZE);
     518  const tr_quark key_int  = tr_quark_new ("this-is-an-int", TR_BAD_SIZE);
     519  const tr_quark key_str  = tr_quark_new ("this-is-a-string", TR_BAD_SIZE);
    520520
    521521  tr_variantInitDict (&top, 0);
Note: See TracChangeset for help on using the changeset viewer.