Skip to content

Commit 1806cd2

Browse files
authored
[hal] Remove useless usage reporting return (#8625)
The value is not used anywhere and it also just returns 0 (was a value from Netcomm in pre-2027).
1 parent 0c44e63 commit 1806cd2

File tree

7 files changed

+24
-31
lines changed

7 files changed

+24
-31
lines changed

hal/src/main/java/org/wpilib/hardware/hal/HAL.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,9 @@ public static void simPeriodicAfter() {
217217
*
218218
* @param resource the used resource name
219219
* @param data arbitrary associated data string
220-
* @return a handle
221220
*/
222-
public static int reportUsage(String resource, String data) {
223-
return UsageReportingJNI.report(resource, data);
221+
public static void reportUsage(String resource, String data) {
222+
UsageReportingJNI.report(resource, data);
224223
}
225224

226225
/**
@@ -230,10 +229,9 @@ public static int reportUsage(String resource, String data) {
230229
* @param resource the used resource name
231230
* @param instanceNumber an index that identifies the resource instance
232231
* @param data arbitrary associated data string
233-
* @return a handle
234232
*/
235-
public static int reportUsage(String resource, int instanceNumber, String data) {
236-
return reportUsage(resource + "[" + instanceNumber + "]", data);
233+
public static void reportUsage(String resource, int instanceNumber, String data) {
234+
reportUsage(resource + "[" + instanceNumber + "]", data);
237235
}
238236

239237
private HAL() {}

hal/src/main/java/org/wpilib/hardware/hal/UsageReportingJNI.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ public class UsageReportingJNI extends JNIWrapper {
1616
*
1717
* @param resource the used resource name
1818
* @param data arbitrary associated data string
19-
* @return a handle
2019
*/
21-
public static native int report(String resource, String data);
20+
public static native void report(String resource, String data);
2221

2322
/** Utility class. */
2423
private UsageReportingJNI() {}

hal/src/main/native/cpp/UsageReporting.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <fmt/format.h>
88

9-
int32_t HAL_ReportUsage(std::string_view resource, int instanceNumber,
10-
std::string_view data) {
11-
return HAL_ReportUsage(fmt::format("{}[{}]", resource, instanceNumber), data);
9+
void HAL_ReportUsage(std::string_view resource, int instanceNumber,
10+
std::string_view data) {
11+
HAL_ReportUsage(fmt::format("{}[{}]", resource, instanceNumber), data);
1212
}

hal/src/main/native/cpp/jni/UsageReportingJNI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ extern "C" {
1818
/*
1919
* Class: org_wpilib_hardware_hal_UsageReportingJNI
2020
* Method: report
21-
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
21+
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
2222
*/
23-
JNIEXPORT jint JNICALL
23+
JNIEXPORT void JNICALL
2424
Java_org_wpilib_hardware_hal_UsageReportingJNI_report
2525
(JNIEnv* env, jclass, jstring resource, jstring data)
2626
{
2727
JStringRef resourceStr{env, resource};
2828
JStringRef dataStr{env, data};
2929
WPI_String resourceWpiStr = wpi::util::make_string(resourceStr);
3030
WPI_String dataWpiStr = wpi::util::make_string(dataStr);
31-
return HAL_ReportUsage(&resourceWpiStr, &dataWpiStr);
31+
HAL_ReportUsage(&resourceWpiStr, &dataWpiStr);
3232
}
3333

3434
} // extern "C"

hal/src/main/native/include/wpi/hal/UsageReporting.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ extern "C" {
2424
* "[instanceNum]" for multiple instances of the same
2525
* resource
2626
* @param data arbitrary associated data string
27-
* @return a handle
2827
*/
29-
int32_t HAL_ReportUsage(const struct WPI_String* resource,
30-
const struct WPI_String* data);
28+
void HAL_ReportUsage(const struct WPI_String* resource,
29+
const struct WPI_String* data);
3130

3231
#ifdef __cplusplus
3332
} // extern "C"
@@ -42,13 +41,11 @@ int32_t HAL_ReportUsage(const struct WPI_String* resource,
4241
* "[instanceNum]" for multiple instances of the same
4342
* resource
4443
* @param data arbitrary associated data string
45-
* @return a handle
4644
*/
47-
inline int32_t HAL_ReportUsage(std::string_view resource,
48-
std::string_view data) {
45+
inline void HAL_ReportUsage(std::string_view resource, std::string_view data) {
4946
WPI_String resourceStr = wpi::util::make_string(resource);
5047
WPI_String dataStr = wpi::util::make_string(data);
51-
return HAL_ReportUsage(&resourceStr, &dataStr);
48+
HAL_ReportUsage(&resourceStr, &dataStr);
5249
}
5350

5451
/**
@@ -58,9 +55,8 @@ inline int32_t HAL_ReportUsage(std::string_view resource,
5855
* @param resource the used resource name
5956
* @param instanceNumber an index that identifies the resource instance
6057
* @param data arbitrary associated data string
61-
* @return a handle
6258
*/
63-
int32_t HAL_ReportUsage(std::string_view resource, int instanceNumber,
64-
std::string_view data);
59+
void HAL_ReportUsage(std::string_view resource, int instanceNumber,
60+
std::string_view data);
6561

6662
#endif

hal/src/main/native/sim/HAL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ void HALSIM_CancelAllSimPeriodicCallbacks(void) {
445445
gSimPeriodicAfter.Reset();
446446
}
447447

448-
int32_t HAL_ReportUsage(const struct WPI_String* resource,
449-
const struct WPI_String* data) {
450-
return 0; // Do nothing for now
448+
void HAL_ReportUsage(const struct WPI_String* resource,
449+
const struct WPI_String* data) {
450+
// Do nothing for now
451451
}
452452

453453
} // extern "C"

hal/src/main/native/systemcore/UsageReporting.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Open Source Software; you can modify and/or share it under the terms of
33
// the WPILib BSD license file in the root directory of this project.
44

5+
#include "wpi/hal/UsageReporting.h"
6+
57
#include <stdint.h>
68

79
#include <fmt/format.h>
@@ -27,8 +29,8 @@ static ::SystemServerUsageReporting* systemServerUsage;
2729

2830
extern "C" {
2931

30-
int32_t HAL_ReportUsage(const struct WPI_String* resource,
31-
const struct WPI_String* data) {
32+
void HAL_ReportUsage(const struct WPI_String* resource,
33+
const struct WPI_String* data) {
3234
auto resourceStr = wpi::util::to_string_view(resource);
3335
auto& publisher = systemServerUsage->publishers[resourceStr];
3436
if (!publisher) {
@@ -38,8 +40,6 @@ int32_t HAL_ReportUsage(const struct WPI_String* resource,
3840
.Publish();
3941
}
4042
publisher.Set(wpi::util::to_string_view(data));
41-
42-
return 0;
4343
}
4444

4545
} // extern "C"

0 commit comments

Comments
 (0)