Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149180644
D48496.1789637001.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D48496.1789637001.diff
View Options
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
--- a/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
@@ -1871,7 +1871,7 @@
buf += sprintf(buf, "none");
}
-static char *bnxt_get_tlv_selector_str(uint8_t selector)
+static const char *bnxt_get_tlv_selector_str(uint8_t selector)
{
switch (selector) {
case BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE:
@@ -1886,24 +1886,23 @@
}
static void
-bnxt_app_tlv_get_string(struct bnxt_softc *softc, char *buf,
- struct bnxt_dcb_app *app, int num)
+bnxt_app_tlv_get_string(struct sbuf *sb, struct bnxt_dcb_app *app, int num)
{
- uint32_t i;
+ int i;
- if (!num) {
- buf += sprintf(buf, " None");
+ if (num == 0) {
+ sbuf_printf(sb, " None");
return;
}
- buf += sprintf(buf, "\n");
+ sbuf_putc(sb, '\n');
for (i = 0; i < num; i++) {
- buf += sprintf(buf, "\tAPP#%0d:\tpri: %d,\tSel: %d,\t%s: %d\n",
- i,
- app[i].priority,
- app[i].selector,
- bnxt_get_tlv_selector_str(app[i].selector),
- app[i].protocol);
+ sbuf_printf(sb, "\tAPP#%0d:\tpri: %d,\tSel: %d,\t%s: %d\n",
+ i,
+ app[i].priority,
+ app[i].selector,
+ bnxt_get_tlv_selector_str(app[i].selector),
+ app[i].protocol);
}
}
@@ -1936,25 +1935,16 @@
static int
bnxt_dcb_list_app(SYSCTL_HANDLER_ARGS)
{
+ struct sbuf sb;
struct bnxt_dcb_app app[128] = {0};
struct bnxt_softc *softc = arg1;
int rc, num_inputs = 0;
- char *buf;
-
-#define BNXT_APP_TLV_STR_LEN 4096
- buf = malloc(BNXT_APP_TLV_STR_LEN, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (!buf)
- return ENOMEM;
+ sbuf_new_for_sysctl(&sb, NULL, 128, req);
bnxt_dcb_ieee_listapp(softc, app, &num_inputs);
- bnxt_app_tlv_get_string(softc, buf, app, num_inputs);
-
- rc = sysctl_handle_string(oidp, buf, BNXT_APP_TLV_STR_LEN, req);
- if (rc || req->newptr == NULL)
- goto end;
-
-end:
- free(buf, M_DEVBUF);
+ bnxt_app_tlv_get_string(&sb, app, num_inputs);
+ rc = sbuf_finish(&sb);
+ sbuf_delete(&sb);
return rc;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 17, 9:23 AM (2 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29725684
Default Alt Text
D48496.1789637001.diff (1 KB)
Attached To
Mode
D48496: bnxt_en: Improve sysctl handler bnxt_dcb_list_app()
Attached
Detach File
Event Timeline
Log In to Comment