MF NetBSD:
- Reduce diffs with NetBSD. - Formatting and explicit values for enum declaration. - Order of prototypes. - zero report_size in hid_clear_local() - errx() needs no newline - Don't initialie variable in declaration in hid_parse_usage_in_page(). - Use fmtcheck() in hid_usage_in_page().
This commit is contained in:
parent
b0850075ac
commit
234e6b87fa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113193
@ -36,7 +36,11 @@ typedef struct report_desc *report_desc_t;
|
||||
typedef struct hid_data *hid_data_t;
|
||||
|
||||
typedef enum hid_kind {
|
||||
hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
|
||||
hid_input = 0,
|
||||
hid_output = 1,
|
||||
hid_feature = 2,
|
||||
hid_collection,
|
||||
hid_endcollection
|
||||
} hid_kind_t;
|
||||
|
||||
typedef struct hid_item {
|
||||
@ -90,11 +94,11 @@ int hid_report_size(report_desc_t d, unsigned int id, enum hid_kind k);
|
||||
int hid_locate(report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h);
|
||||
|
||||
/* Conversion to/from usage names, usage.c: */
|
||||
int hid_parse_usage_page(const char *name);
|
||||
int hid_parse_usage_in_page(const char *name);
|
||||
const char *hid_usage_page(int i);
|
||||
const char *hid_usage_in_page(unsigned int u);
|
||||
void hid_init(const char *file);
|
||||
int hid_parse_usage_in_page(const char *name);
|
||||
int hid_parse_usage_page(const char *name);
|
||||
|
||||
/* Extracting/insertion of data, data.c: */
|
||||
int hid_get_data(const void *p, const hid_item_t *h);
|
||||
|
@ -74,6 +74,7 @@ hid_clear_local(hid_item_t *c)
|
||||
c->string_minimum = 0;
|
||||
c->string_maximum = 0;
|
||||
c->set_delimiter = 0;
|
||||
c->report_size = 0;
|
||||
}
|
||||
|
||||
hid_data_t
|
||||
|
@ -96,7 +96,7 @@ hid_init(const char *hidname)
|
||||
no = -1;
|
||||
else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 &&
|
||||
sscanf(line, " %d %[^\n]", &no, name) != 2)
|
||||
errx(1, "file %s, line %d, syntax error\n",
|
||||
errx(1, "file %s, line %d, syntax error",
|
||||
hidname, lineno);
|
||||
for (p = name; *p; p++)
|
||||
if (isspace(*p) || *p == '.')
|
||||
@ -106,7 +106,7 @@ hid_init(const char *hidname)
|
||||
err(1, "strdup");
|
||||
if (isspace(line[0])) {
|
||||
if (!curpage)
|
||||
errx(1, "file %s, line %d, syntax error\n",
|
||||
errx(1, "file %s, line %d, syntax error",
|
||||
hidname, lineno);
|
||||
if (curpage->pagesize >= curpage->pagesizemax) {
|
||||
curpage->pagesizemax += 10;
|
||||
@ -160,7 +160,7 @@ hid_usage_page(int i)
|
||||
int k;
|
||||
|
||||
if (!pages)
|
||||
errx(1, "no hid table\n");
|
||||
errx(1, "no hid table");
|
||||
|
||||
for (k = 0; k < npages; k++)
|
||||
if (pages[k].usage == i)
|
||||
@ -185,8 +185,9 @@ hid_usage_in_page(unsigned int u)
|
||||
for (j = 0; j < pages[k].pagesize; j++) {
|
||||
us = pages[k].page_contents[j].usage;
|
||||
if (us == -1) {
|
||||
sprintf(b, "%s %d",
|
||||
pages[k].page_contents[j].name, i);
|
||||
sprintf(b,
|
||||
fmtcheck(pages[k].page_contents[j].name, "%d"),
|
||||
i);
|
||||
return b;
|
||||
}
|
||||
if (us == i)
|
||||
@ -203,7 +204,7 @@ hid_parse_usage_page(const char *name)
|
||||
int k;
|
||||
|
||||
if (!pages)
|
||||
errx(1, "no hid table\n");
|
||||
errx(1, "no hid table");
|
||||
|
||||
for (k = 0; k < npages; k++)
|
||||
if (strcmp(pages[k].name, name) == 0)
|
||||
@ -215,10 +216,11 @@ hid_parse_usage_page(const char *name)
|
||||
int
|
||||
hid_parse_usage_in_page(const char *name)
|
||||
{
|
||||
const char *sep = strchr(name, ':');
|
||||
const char *sep;
|
||||
int k, j;
|
||||
unsigned int l;
|
||||
|
||||
sep = strchr(name, ':');
|
||||
if (sep == NULL)
|
||||
return -1;
|
||||
l = sep - name;
|
||||
|
@ -36,7 +36,11 @@ typedef struct report_desc *report_desc_t;
|
||||
typedef struct hid_data *hid_data_t;
|
||||
|
||||
typedef enum hid_kind {
|
||||
hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
|
||||
hid_input = 0,
|
||||
hid_output = 1,
|
||||
hid_feature = 2,
|
||||
hid_collection,
|
||||
hid_endcollection
|
||||
} hid_kind_t;
|
||||
|
||||
typedef struct hid_item {
|
||||
@ -90,11 +94,11 @@ int hid_report_size(report_desc_t d, unsigned int id, enum hid_kind k);
|
||||
int hid_locate(report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h);
|
||||
|
||||
/* Conversion to/from usage names, usage.c: */
|
||||
int hid_parse_usage_page(const char *name);
|
||||
int hid_parse_usage_in_page(const char *name);
|
||||
const char *hid_usage_page(int i);
|
||||
const char *hid_usage_in_page(unsigned int u);
|
||||
void hid_init(const char *file);
|
||||
int hid_parse_usage_in_page(const char *name);
|
||||
int hid_parse_usage_page(const char *name);
|
||||
|
||||
/* Extracting/insertion of data, data.c: */
|
||||
int hid_get_data(const void *p, const hid_item_t *h);
|
||||
|
Loading…
Reference in New Issue
Block a user