lttng-ctl rotate: fix: possible unaligned access in packed structure
[lttng-tools.git] / src / lib / lttng-ctl / rotate.c
index d9871dc9d3e9f6c651126f917d765321adc116f2..bc3a63cc8aa67d8a0bd089e32b56677d0795039f 100644 (file)
@@ -233,7 +233,7 @@ int lttng_rotate_session(const char *session_name,
                        sizeof(lsm.session.name));
 
        ret = lttng_ctl_ask_sessiond(&lsm, (void **) &rotate_return);
-       if (ret < 0) {
+       if (ret <= 0) {
                *rotation_handle = NULL;
                goto end;
        }
@@ -299,29 +299,33 @@ enum lttng_rotation_status lttng_rotation_update_schedule(
        switch (schedule->type) {
        case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
        {
+               uint64_t threshold;
+
                status = lttng_rotation_schedule_size_threshold_get_threshold(
-                               schedule, &lsm.u.rotation_set_schedule.value);
+                               schedule, &threshold);
                if (status != LTTNG_ROTATION_STATUS_OK) {
                        if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
                                status = LTTNG_ROTATION_STATUS_INVALID;
                        }
                        goto end;
                }
-
+               lsm.u.rotation_set_schedule.value = threshold;
                lsm.u.rotation_set_schedule.set = !!add;
                break;
        }
        case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
        {
+               uint64_t period;
+
                status = lttng_rotation_schedule_periodic_get_period(
-                               schedule, &lsm.u.rotation_set_schedule.value);
+                               schedule, &period);
                if (status != LTTNG_ROTATION_STATUS_OK) {
                        if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
                                status = LTTNG_ROTATION_STATUS_INVALID;
                        }
                        goto end;
                }
-
+               lsm.u.rotation_set_schedule.value = period;
                lsm.u.rotation_set_schedule.set = !!add;
                break;
        }
This page took 0.026317 seconds and 4 git commands to generate.