[bug report] HID: haptic: initialize haptic device
From: Dan Carpenter <hidden>
Date: 2025-09-18 09:47:02
Hello Angela Czubak,
Commit 344ff3584957 ("HID: haptic: initialize haptic device") from
Aug 18, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/hid/hid-haptic.c:193 fill_effect_buf()
error: uninitialized symbol 'value'.
drivers/hid/hid-haptic.c
147 static void fill_effect_buf(struct hid_haptic_device *haptic,
148 struct ff_haptic_effect *effect,
149 struct hid_haptic_effect *haptic_effect,
150 int waveform_ordinal)
151 {
152 struct hid_report *rep = haptic->manual_trigger_report;
153 struct hid_usage *usage;
154 struct hid_field *field;
155 s32 value;
156 int i, j;
157 u8 *buf = haptic_effect->report_buf;
158
159 mutex_lock(&haptic->manual_trigger_mutex);
160 for (i = 0; i < rep->maxfield; i++) {
161 field = rep->field[i];
162 /* Ignore if report count is out of bounds. */
163 if (field->report_count < 1)
164 continue;
165
166 for (j = 0; j < field->maxusage; j++) {
167 usage = &field->usage[j];
168
169 switch (usage->hid) {
170 case HID_HP_INTENSITY:
171 if (effect->intensity > 100) {
172 value = field->logical_maximum;
173 } else {
174 value = field->logical_minimum +
175 effect->intensity *
176 (field->logical_maximum -
177 field->logical_minimum) / 100;
178 }
179 break;
180 case HID_HP_REPEATCOUNT:
181 value = effect->repeat_count;
182 break;
183 case HID_HP_RETRIGGERPERIOD:
184 value = effect->retrigger_period;
185 break;
186 case HID_HP_MANUALTRIGGER:
187 value = waveform_ordinal;
188 break;
189 default:
190 break;
value is not set on the default path.
191 }
192
--> 193 field->value[j] = value;
194 }
195 }
196
197 hid_output_report(rep, buf);
198 mutex_unlock(&haptic->manual_trigger_mutex);
199 }
regards,
dan carpenter