mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-06 12:50:07 +02:00
gparamspecs: Use standard min/max constants rather than literals
This makes the code a little clearer. In most cases, it’s not a functional change. In a few cases, the values are different. I believe the original values were incorrect (accidentally transposed, perhaps). This never caused an issue because they were all immediately overwritten during construction of a `GParamSpec`: these values were defaults in the `instance_init` vfunc of the `GTypeInstance` for a `GParamSpec`, but the actual min/max for the `GParamSpec` instance were immediately written over them in the constructor (such as `g_param_spec_int()`). Spotted in !4593. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
parent
988db0e89d
commit
d425135164
@ -47,8 +47,8 @@ param_char_init (GParamSpec *pspec)
|
|||||||
{
|
{
|
||||||
GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
|
GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
|
||||||
|
|
||||||
cspec->minimum = 0x7f;
|
cspec->minimum = CHAR_MIN;
|
||||||
cspec->maximum = 0x80;
|
cspec->maximum = CHAR_MAX;
|
||||||
cspec->default_value = 0;
|
cspec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ param_uchar_init (GParamSpec *pspec)
|
|||||||
GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
|
GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
|
||||||
|
|
||||||
uspec->minimum = 0;
|
uspec->minimum = 0;
|
||||||
uspec->maximum = 0xff;
|
uspec->maximum = UCHAR_MAX;
|
||||||
uspec->default_value = 0;
|
uspec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ param_int_init (GParamSpec *pspec)
|
|||||||
{
|
{
|
||||||
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
|
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
|
||||||
|
|
||||||
ispec->minimum = (int) 0x7fffffff;
|
ispec->minimum = INT_MIN;
|
||||||
ispec->maximum = (int) 0x80000000;
|
ispec->maximum = INT_MAX;
|
||||||
ispec->default_value = 0;
|
ispec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ param_uint_init (GParamSpec *pspec)
|
|||||||
GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
|
GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
|
||||||
|
|
||||||
uspec->minimum = 0;
|
uspec->minimum = 0;
|
||||||
uspec->maximum = 0xffffffff;
|
uspec->maximum = UINT_MAX;
|
||||||
uspec->default_value = 0;
|
uspec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,13 +252,8 @@ param_long_init (GParamSpec *pspec)
|
|||||||
{
|
{
|
||||||
GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
|
GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
|
||||||
|
|
||||||
#if SIZEOF_LONG == 4
|
lspec->minimum = LONG_MIN;
|
||||||
lspec->minimum = (glong) 0x7fffffff;
|
lspec->maximum = LONG_MAX;
|
||||||
lspec->maximum = (glong) 0x80000000;
|
|
||||||
#else /* SIZEOF_LONG != 4 (8) */
|
|
||||||
lspec->minimum = (glong) 0x7fffffffffffffff;
|
|
||||||
lspec->maximum = (glong) 0x8000000000000000;
|
|
||||||
#endif
|
|
||||||
lspec->default_value = 0;
|
lspec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,11 +303,7 @@ param_ulong_init (GParamSpec *pspec)
|
|||||||
GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
|
GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
|
||||||
|
|
||||||
uspec->minimum = 0;
|
uspec->minimum = 0;
|
||||||
#if SIZEOF_LONG == 4
|
uspec->maximum = ULONG_MAX;
|
||||||
uspec->maximum = 0xffffffff;
|
|
||||||
#else /* SIZEOF_LONG != 4 (8) */
|
|
||||||
uspec->maximum = 0xffffffffffffffff;
|
|
||||||
#endif
|
|
||||||
uspec->default_value = 0;
|
uspec->default_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user