Zdenek Styblik
2013-12-09 08:51:03 UTC
Hello Jordan,
since SF.net kinda sucks, let's do code review over e-mail.
~~~
+<<<<<<< ipmi_mc.h
+/* IPMI 2.0 command for system information*/
[...]
+=======
[...]
+>>>>>>> 1.12
~~~
Errr ... what???
~~~
+int ipmi_getsysinfo(struct ipmi_intf * intf, int param, int block, int set,
+ int len, void *buffer);
+int ipmi_setsysinfo(struct ipmi_intf * intf, int len, void *buffer);
~~~
If you want to make these available outside of 'lib/ipmi_mc.c', then
names of these functions must be 'ipmi_mc_...'. Therefore, two
steps/tickets are required. One is to change names of these functions
and second is the one under discussion.
~~~
+#define IPMI_CMD_SET_PEF_CONFIG_PARMS 0x12
+struct pef_cfgparm_set_policy_table_entry
+{
+ uint8_t id;
+ uint8_t sel;
+ struct pef_policy_entry entry;
+} ATTRIBUTE_PACKING;
~~~
Such things go into header file. Also, where is check whether
ATTRIBUTE_PACKING is supported/defined? What if it isn't???
~~~
+ rsp = ipmi_pef_msg_exchange(intf, &req, "Set Alert policy table entry");
+ if (!rsp) {
+ lprintf(LOG_ERR, " **Error setting Alert policy table entry");
+ return -1;
+ }
+ return 0;
~~~
No check for ccode? Huh?
~~~
+static void
+ipmi_pef_policy_enable(struct ipmi_intf * intf, int set, int enable)
+{
~~~
No, this function *returns* integer.
~~~
+ if (ptbl) {
+ free(ptbl);
+ }
~~~
You've missed ``ptbl = NULL;'' there.
~~~
+ if (set > 0 && set <= tbl_size) {
[...]
+ } else {
+ lprintf(LOG_ERR, "Invalid policy index, valid range =
(1..%d)", tbl_size);
+ }
~~~
Invert ``if'' and return early.
~~~
+static struct valstr endis[] = {
+ { .str = "enable", .val = 0x01 },
+ { .str = "disable", .val = 0x00 },
+ { .val = -1 },
+};
+
~~~
No, use strcmp()/strncmp() or whatever.
~~~
+ else if (!strncmp(argv[0], "setpolicy", 6)) {
~~~
Now, I'm not exactly fond of adding 'setpolicy'. How about to give
'pef' a bit of thought and redesign 'pef' cli interface? I find it
rather, well, not good, to be honest. And this isn't making it any
better.
I can only wonder why there isn't something like 'pef list
<policy|entry>' instead of 'policy' which lists policies and 'list'
which list entries. I'm sorry, but it makes no sense.
~~~
+ if (argc > 2) {
+ str2int(argv[1], &set);
~~~
A good one. :)
Also, please, read
http://sourceforge.net/p/ipmitool/wiki/coding_standards/ and change
code formatting in your patch.
Best regards,
Z.
--
Zdenek Styblik
email: ***@gmail.com
jabber: ***@gmail.com
since SF.net kinda sucks, let's do code review over e-mail.
~~~
+<<<<<<< ipmi_mc.h
+/* IPMI 2.0 command for system information*/
[...]
+=======
[...]
+>>>>>>> 1.12
~~~
Errr ... what???
~~~
+int ipmi_getsysinfo(struct ipmi_intf * intf, int param, int block, int set,
+ int len, void *buffer);
+int ipmi_setsysinfo(struct ipmi_intf * intf, int len, void *buffer);
~~~
If you want to make these available outside of 'lib/ipmi_mc.c', then
names of these functions must be 'ipmi_mc_...'. Therefore, two
steps/tickets are required. One is to change names of these functions
and second is the one under discussion.
~~~
+#define IPMI_CMD_SET_PEF_CONFIG_PARMS 0x12
+struct pef_cfgparm_set_policy_table_entry
+{
+ uint8_t id;
+ uint8_t sel;
+ struct pef_policy_entry entry;
+} ATTRIBUTE_PACKING;
~~~
Such things go into header file. Also, where is check whether
ATTRIBUTE_PACKING is supported/defined? What if it isn't???
~~~
+ rsp = ipmi_pef_msg_exchange(intf, &req, "Set Alert policy table entry");
+ if (!rsp) {
+ lprintf(LOG_ERR, " **Error setting Alert policy table entry");
+ return -1;
+ }
+ return 0;
~~~
No check for ccode? Huh?
~~~
+static void
+ipmi_pef_policy_enable(struct ipmi_intf * intf, int set, int enable)
+{
~~~
No, this function *returns* integer.
~~~
+ if (ptbl) {
+ free(ptbl);
+ }
~~~
You've missed ``ptbl = NULL;'' there.
~~~
+ if (set > 0 && set <= tbl_size) {
[...]
+ } else {
+ lprintf(LOG_ERR, "Invalid policy index, valid range =
(1..%d)", tbl_size);
+ }
~~~
Invert ``if'' and return early.
~~~
+static struct valstr endis[] = {
+ { .str = "enable", .val = 0x01 },
+ { .str = "disable", .val = 0x00 },
+ { .val = -1 },
+};
+
~~~
No, use strcmp()/strncmp() or whatever.
~~~
+ else if (!strncmp(argv[0], "setpolicy", 6)) {
~~~
Now, I'm not exactly fond of adding 'setpolicy'. How about to give
'pef' a bit of thought and redesign 'pef' cli interface? I find it
rather, well, not good, to be honest. And this isn't making it any
better.
I can only wonder why there isn't something like 'pef list
<policy|entry>' instead of 'policy' which lists policies and 'list'
which list entries. I'm sorry, but it makes no sense.
~~~
+ if (argc > 2) {
+ str2int(argv[1], &set);
~~~
A good one. :)
Also, please, read
http://sourceforge.net/p/ipmitool/wiki/coding_standards/ and change
code formatting in your patch.
Best regards,
Z.
--
Zdenek Styblik
email: ***@gmail.com
jabber: ***@gmail.com