Skip to content

Fix: Fix clang-format issues for tdishr C codebase#2998

Open
santorofer wants to merge 1 commit into
MDSplus:alphafrom
santorofer:clang-format-fixes
Open

Fix: Fix clang-format issues for tdishr C codebase#2998
santorofer wants to merge 1 commit into
MDSplus:alphafrom
santorofer:clang-format-fixes

Conversation

@santorofer

@santorofer santorofer commented Dec 9, 2025

Copy link
Copy Markdown
Contributor
  • clang-format introduced weird formatting issues for certain section of the tdishr codebase. Those issues were fixed manually.
  • Some refactor of the code was needed for those fixes.

@santorofer santorofer self-assigned this Jan 7, 2026
* 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.
Comment thread tdishr/TdiArray.c
break;
}
return status;
return status;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra semicolon on this line. The ;; should instead just be ;.

Comment thread tdishr/TdiAbs.c
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this line, so it reads as follows:

case DTYPE_D:
   start_operate2(double);
   double ans = 0.0;

Comment thread tdishr/TdiAbs.c
if (STATUS_NOT_OK)
return status;
switch (in_ptr->dtype)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this blank line.

Comment thread tdishr/TdiAbs.c
NintComplex(DTYPE_FT);
end_operate default : status = TdiINVDTYDSC;
case DTYPE_BU:
start_operate(uint8_t) out[i] = in[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this into two lines.

Comment thread tdishr/TdiArray.c
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};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Append this to the previous line for descriptor con1.

Comment thread tdishr/TdiDivide.c
: 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformat this line. Plus, the three lines that follow.

Comment thread tdishr/TdiDivide.c
case DTYPE_FTC:
OperateC(double, DTYPE_FT);
default :
return TdiINVDTYDSC;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this line.

Comment thread tdishr/TdiGetData.c
case DTYPE_L:
*val_ptr = (float)*(int *)in_ptr->pointer;
break;
default:

@mwinkel-dev mwinkel-dev Apr 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the following lines that are part of the default: case.

Comment thread tdishr/TdiGetData.c
break;
case DTYPE_WINDOW:
status = TdiUnits(((struct descriptor_window *)rptr)->value_at_idx0,
out_ptr MDS_END_ARG);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Append to preceding line.

Comment thread tdishr/TdiGetData.c
break;
case DTYPE_WITH_UNITS:
status = TdiData(((struct descriptor_with_units *)rptr)->units,
out_ptr MDS_END_ARG);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Append to preceding line.

Comment thread tdishr/TdiGetData.c
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this block (it is the body of the 'default:`).

Comment thread tdishr/TdiApd.c
{0},
1,
0};
struct descriptor_a arr = {sizeof(void *), (unsigned char)(dtype & 0xff), CLASS_APD, (void *)0, 0, 0, {0}, 1, 0};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
};

Comment thread tdishr/TdiArray.c
**********************************************************/
default:
default:
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tdishr/TdiExponent.c
@@ -1,3 +1,4 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded white space change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants