Skip to content

Commit

Permalink
fix clang format + ret uninitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
pkotamnives committed Jan 15, 2024
1 parent a569fcd commit a5c8a04
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 42 deletions.
61 changes: 29 additions & 32 deletions projects/cm_mcu/ZynqMonTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ void zm_set_uptime(struct zynqmon_data_t data[], int start)
now_16 = (now >> 16) & 0xFFFFU; // upper 16 bits
data[1].sensor = start + 1;
data[1].data.us = now_16;

}

// wasting half the data packet here; could repack it
Expand All @@ -302,34 +301,34 @@ void zm_set_firefly_temps(struct zynqmon_data_t data[], int start)
#ifdef REV2
uint16_t getFFtXdisenablebit(const uint8_t i)
{
if (i > NFIREFLIES_F1 + NFIREFLIES_F2) {
log_warn(LOG_SERVICE, "caught %d > total fireflies %d\r\n", i, NFIREFLIES);
return 56;
}
uint8_t val = 56;
int i2c_dev;
if (!isEnabledFF(i)) // skip the FF if it's not enabled via the FF config
return val;
if (i < NFIREFLIES_F1) {
i2c_dev = I2C_DEVICE_F1;
}
else {
i2c_dev = I2C_DEVICE_F2;
}
int ret;
if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) {
ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_TX_DISABLE_REG, &val, 1, i2c_dev);
}
else if (strstr(ff_moni2c_addrs[i].name, "Tx") != NULL) {
ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_14G_TX_DISABLE_REG, &val, 1, i2c_dev);
}
if (ret !=0)
return 56;
else
return val;
if (i > NFIREFLIES_F1 + NFIREFLIES_F2) {
log_warn(LOG_SERVICE, "caught %d > total fireflies %d\r\n", i, NFIREFLIES);
return 56;
}
uint8_t val = 56;
int i2c_dev;
if (!isEnabledFF(i)) // skip the FF if it's not enabled via the FF config
return val;
if (i < NFIREFLIES_F1) {
i2c_dev = I2C_DEVICE_F1;
}
else {
i2c_dev = I2C_DEVICE_F2;
}
int ret = -99;
if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) {
ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_TX_DISABLE_REG, &val, 1, i2c_dev);
}
else if (strstr(ff_moni2c_addrs[i].name, "Tx") != NULL) {
ret = read_ff_register(ff_moni2c_addrs[i].name, ECU0_14G_TX_DISABLE_REG, &val, 1, i2c_dev);
}
if (ret != 0)
return 56;
else
return val;
}
// updated once per loop.
//For each firefly device, send
// For each firefly device, send
// (1) ffpart-bit (1 for 25GBs FFL, else 0)
// (2) present-bit
// (3) tx-disable-bit (e.g. via ECU0_14G_TX_DISABLE_REG)
Expand Down Expand Up @@ -432,18 +431,16 @@ void zm_set_firefly_info(struct zynqmon_data_t data[], int start)
}
data[ll].sensor = ll + start;
++ll;


if (isFFStale()) {
data[ll].data.us = 0xff; // special stale value
data[ll].data.us = 0xff; // special stale value
}
else {
data[ll].data.us = getFFtXdisenablebit(j); // sensor value and type
log_debug(LOG_SERVICE, "TX-disenabled? for ff argv %d: 0x%02x\r\n", j, getFFtXdisenablebit(j));
data[ll].data.us = getFFtXdisenablebit(j); // sensor value and type
log_debug(LOG_SERVICE, "TX-disenabled? for ff argv %d: 0x%02x\r\n", j, getFFtXdisenablebit(j));
}
data[ll].sensor = ll + start;
++ll;

}
}

Expand Down
1 change: 0 additions & 1 deletion projects/cm_mcu/commands/SensorControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "common/smbus_helper.h"
#include "Tasks.h"


int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value, size_t size, int i2c_device)
{
memset(value, 0, size);
Expand Down
2 changes: 0 additions & 2 deletions projects/cm_mcu/commands/SensorControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ BaseType_t ff_status(int argc, char **argv, char *m);
BaseType_t ff_los_alarm(int argc, char **argv, char *m);
BaseType_t ff_cdr_lol_alarm(int argc, char **argv, char *m);


// Clocks
BaseType_t clkmon_ctl(int argc, char **argv, char *m);
BaseType_t clkr0amon_ctl(int argc, char **argv, char *m);
Expand All @@ -66,5 +65,4 @@ BaseType_t fpga_flash(int argc, char **argv, char *m);

int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value, size_t size, int i2c_device);


#endif
13 changes: 6 additions & 7 deletions sm_cm_config/src/xml_generate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#!/ usr / bin / env python
"""Generate XML file from YAML input"""
import xml.etree.ElementTree as ET
from pprint import pprint
Expand All @@ -10,8 +10,8 @@
def make_node(parent: ET.Element, myid: str, thedict: dict, addr2: int, bit: int,
parent_id: str) -> ET.Element:
"""create the node to be inserted into the xml tree"""
# pylint: disable=too-many-branches
# I disable this check because as far as I can tell it's wrong
#pylint : disable = too - many - branches
#I disable this check because as far as I can tell it's wrong
thenode = ET.SubElement(parent, 'node')
myid = myid.replace(' ', '_')
thenode.set('id', myid)
Expand Down Expand Up @@ -117,8 +117,7 @@ def overloads(self):
return True
return False


# custom file type for yaml file, to be used with argparse
#custom file type for yaml file, to be used with argparse
def yaml_file(filename):
"""custom file type for yaml file, to be used with argparse"""
if not filename.endswith('.yml'):
Expand All @@ -129,7 +128,7 @@ def yaml_file(filename):
parser.add_argument('-v', '--verbose', action='store_true',
help='increase output verbosity')
parser.add_argument('-d', '--directory', type=str, help='output directory')
# this argument is required, one input file ending with yaml extension
#this argument is required, one input file ending with yaml extension
parser.add_argument('input_file', metavar='file', type=yaml_file,
help='input yaml file name')

Expand Down Expand Up @@ -202,7 +201,7 @@ def yaml_file(filename):
i += 1
tree = ET.ElementTree(cm)
ET.indent(tree, space='\t')
# create output file name based on input file, replacing 'yml' with 'xml'
#create output file name based on input file, replacing 'yml' with 'xml'
out_name = os.path.basename(args.input_file)[:-len('.yml')] + '.xml'
out_name = args.directory + '/' + out_name
if args.verbose:
Expand Down

0 comments on commit a5c8a04

Please sign in to comment.