Skip to content

remove 'unused step' warnings from kernels without pd#737

Open
pkienzle wants to merge 1 commit into
masterfrom
fix-unused-kernel-parameter-warnings
Open

remove 'unused step' warnings from kernels without pd#737
pkienzle wants to merge 1 commit into
masterfrom
fix-unused-kernel-parameter-warnings

Conversation

@pkienzle

@pkienzle pkienzle commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

For models without polydispersity, the c compiler was returning warnings about an unused step parameter for every variant of the calculator (Iq, Iqxy, Imagnetic). This made it hard to see the actual error.

After the fix the following

2026-06-01 21:49:10,725 : ERROR : sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor (TabbedModelEditor.py:466) :: Error building model: compile failed.
cc -std=c99 -O2 -Wall -fPIC -shared /tmp/sas64_arm64_yuk_29A943E8_egi_n035.c -o ".../SasView/compiled_models/sas64_arm64_yuk_29A943E8.so" -lm
.../SasView/plugin_models/yuk.py:65:5: error: use of undeclared identifier 'broken'
   65 |     broken;
      |     ^~~~~~
./kernel_iq.c Iq:677:5: warning: variable 'step' set but not used [-Wunused-but-set-variable]
  677 | int step = pd_start;
      |     ^
./kernel_iq.c Iqxy:677:5: warning: variable 'step' set but not used [-Wunused-but-set-variable]
  677 | int step = pd_start;
      |     ^
./kernel_iq.c Imagnetic:677:5: warning: variable 'step' set but not used [-Wunused-but-set-variable]
  677 | int step = pd_start;
      |     ^
3 warnings and 1 error generated.

becomes

2026-06-01 21:53:07,905 : ERROR : sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor (TabbedModelEditor.py:466) :: Error building model: compile failed.
cc -std=c99 -O2 -Wall -fPIC -shared /tmp/sas64_arm64_yuk_756BDC0C_cb1sfuot.c -o ".../SasView/compiled_models/sas64_arm64_yuk_756BDC0C.so" -lm
.../SasView/plugin_models/yuk.py:65:5: error: use of undeclared identifier 'broken'
   65 |     broken;
      |     ^~~~~~
1 error generated.

@krzywon krzywon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code seems reasonable. Haven't tested.

@pkienzle

pkienzle commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

CI runs C models with and without polydipersity. Since everything still passes it doesn't break anything.

Showing that the warning doesn't appear on your system is more complicated because compiler output is suppressed if there are no errors. I modified sasmodes/models/guinier.c with:

...
#warning "this is a warning"
#error "this is an error"

then ran the model under cpu and gpu respectively:

python -m sasmodels.compare -single! guinier
python -m sasmodels.compare -single guinier

In this branch on mac os I only got the above warning and error. On master I got the unused variable warning for -single! (cpu) but not for -single (gpu).

@krzywon krzywon requested a review from butlerpd June 16, 2026 13:53
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.

2 participants