Fix: Fix clang-format issues for tdishr C codebase#2998
Conversation
* cland-format introduced strange formating issues for certain section of the tdishr codebase. Those issues were fixed manually. * Some refactor of the code was needed for those fixes.
a3dd0b6 to
9866636
Compare
| break; | ||
| } | ||
| return status; | ||
| return status;; |
There was a problem hiding this comment.
There is an extra semicolon on this line. The ;; should instead just be ;.
| double ans = 0.0; | ||
| CvtConvertFloat(&ans, DTYPE_NATIVE_DOUBLE, &out[i], DTYPE_G, 0); | ||
| end_operate; | ||
| case DTYPE_D: start_operate2(double) double ans = 0.0; |
There was a problem hiding this comment.
Split this line, so it reads as follows:
case DTYPE_D:
start_operate2(double);
double ans = 0.0;
| if (STATUS_NOT_OK) | ||
| return status; | ||
| switch (in_ptr->dtype) | ||
|
|
There was a problem hiding this comment.
Delete this blank line.
| NintComplex(DTYPE_FT); | ||
| end_operate default : status = TdiINVDTYDSC; | ||
| case DTYPE_BU: | ||
| start_operate(uint8_t) out[i] = in[i]; |
There was a problem hiding this comment.
Split this into two lines.
| static const struct descriptor con0 = {sizeof(int), DTYPE_L, CLASS_S,(char *)&i0}; | ||
| static const struct descriptor con1 = {sizeof(int), DTYPE_L, CLASS_S, | ||
| (char *)&i1}; | ||
| (char *)&i1}; |
There was a problem hiding this comment.
Append this to the previous line for descriptor con1.
| : OperateC(double, DTYPE_D) case DTYPE_FTC | ||
| : OperateC(double, DTYPE_FT) default : return TdiINVDTYDSC; | ||
| case DTYPE_B: | ||
| Operate(char) case DTYPE_BU : Operate(unsigned char) case DTYPE_W |
There was a problem hiding this comment.
Reformat this line. Plus, the three lines that follow.
| case DTYPE_FTC: | ||
| OperateC(double, DTYPE_FT); | ||
| default : | ||
| return TdiINVDTYDSC; |
| case DTYPE_L: | ||
| *val_ptr = (float)*(int *)in_ptr->pointer; | ||
| break; | ||
| default: |
There was a problem hiding this comment.
Indent the following lines that are part of the default: case.
| break; | ||
| case DTYPE_WINDOW: | ||
| status = TdiUnits(((struct descriptor_window *)rptr)->value_at_idx0, | ||
| out_ptr MDS_END_ARG); |
There was a problem hiding this comment.
Append to preceding line.
| break; | ||
| case DTYPE_WITH_UNITS: | ||
| status = TdiData(((struct descriptor_with_units *)rptr)->units, | ||
| out_ptr MDS_END_ARG); |
There was a problem hiding this comment.
Append to preceding line.
| mdsdsc_t val_dsc = {sizeof(int), DTYPE_L, CLASS_S, 0}; | ||
| val_dsc.pointer = (char *)val_ptr; | ||
| status = TdiConvert(in_ptr, &val_dsc MDS_END_ARG); | ||
| } |
There was a problem hiding this comment.
Indent this block (it is the body of the 'default:`).
| {0}, | ||
| 1, | ||
| 0}; | ||
| struct descriptor_a arr = {sizeof(void *), (unsigned char)(dtype & 0xff), CLASS_APD, (void *)0, 0, 0, {0}, 1, 0}; |
There was a problem hiding this comment.
This isn't blocking but the length of this line feels really long to me. I agree a new line for each variable is extreme but maybe a middle ground.
struct descriptor_a arr = {
sizeof(void *), (unsigned char)(dtype & 0xff), CLASS_APD,
(void *)0, 0, 0, {0}, 1, 0
};| **********************************************************/ | ||
| default: | ||
| default: | ||
| { |
There was a problem hiding this comment.
Do we want to keep the outer curly braces here? I can see either way because it does help keep the reader in context but also, they aren't needed.
There was a problem hiding this comment.
Two conjectures as to why there are curly braces: clarity and scope. As Tim suggests, perhaps clarity was the motivation -- that having the entire default clause in a curly braces was intended to make it easier to read. Or perhaps the use of curly braces was to emphasize that the new local variable will be destroyed when control flow exits the block.
Regardless, Tim is correct that the curly braces aren't needed.
| @@ -1,3 +1,4 @@ | |||
|
|
|||
There was a problem hiding this comment.
Unneeded white space change.
Uh oh!
There was an error while loading. Please reload this page.