Skip to content

Commit 51ace79

Browse files
committed
Also ensure that Component buildorder property is signed
Fixes: #77 Signed-off-by: Stephen Gallagher <[email protected]>
1 parent 7b1c167 commit 51ace79

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

modulemd/v1/modulemd-component.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ modulemd_component_set_property (GObject *gobject,
294294
switch (property_id)
295295
{
296296
case COMPONENT_PROP_BUILDORDER:
297-
modulemd_component_set_buildorder (self, g_value_get_uint64 (value));
297+
modulemd_component_set_buildorder (self, g_value_get_int64 (value));
298298
break;
299299

300300
case COMPONENT_PROP_NAME:
@@ -322,7 +322,7 @@ modulemd_component_get_property (GObject *gobject,
322322
switch (property_id)
323323
{
324324
case COMPONENT_PROP_BUILDORDER:
325-
g_value_set_uint64 (value, modulemd_component_peek_buildorder (self));
325+
g_value_set_int64 (value, modulemd_component_peek_buildorder (self));
326326
break;
327327

328328
case COMPONENT_PROP_NAME:
@@ -375,13 +375,13 @@ modulemd_component_class_init (ModulemdComponentClass *klass)
375375
klass->copy = NULL;
376376

377377
component_properties[COMPONENT_PROP_BUILDORDER] =
378-
g_param_spec_uint64 ("buildorder",
379-
"Build order",
380-
"The buildorder index for this component.",
381-
0,
382-
G_MAXUINT64,
383-
0,
384-
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
378+
g_param_spec_int64 ("buildorder",
379+
"Build order",
380+
"The buildorder index for this component.",
381+
G_MININT64,
382+
G_MAXINT64,
383+
0,
384+
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
385385

386386
component_properties[COMPONENT_PROP_NAME] =
387387
g_param_spec_string ("name",

modulemd/v1/tests/test-modulemd-python.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ def test_issue33(self):
188188
"%s/mod-defaults/spec.v1.yaml" % os.getenv('MESON_SOURCE_ROOT'))
189189
print(defs)
190190

191+
def test_issue77(self):
192+
# This would crash on a type constraint accepting a signed value
193+
component = Modulemd.ComponentRpm(name="pkg1",
194+
rationale="Just because",
195+
buildorder=-1)
196+
assert component.props.buildorder == -1
197+
198+
component.props.buildorder = -2
199+
assert component.get_buildorder() == -2
200+
201+
component.set_buildorder(5)
202+
assert component.props.buildorder == 5
203+
191204

192205
class TestIntent(unittest.TestCase):
193206

0 commit comments

Comments
 (0)