Skip to content

Commit

Permalink
Fix for bug #68
Browse files Browse the repository at this point in the history
- Bumped PROGRAM_VERSION to 1.3.3
- Added checks for getsubopt() returned value parameter during driver start-up.
  • Loading branch information
Deniz-Eren committed May 28, 2024
1 parent 333b7f0 commit 26553fa
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/PROGRAM_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.2
1.3.3
74 changes: 74 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,32 @@ int main (int argc, char* argv[]) {
while (*options != '\0') {
switch (getsubopt(&options, sub_opts, &value)) {
case CHANNEL_ID: /* process id option */
if (value == NULL) {
printf("error with channel id sub-option\n");

return EXIT_FAILURE;
}

new_channel_config.id = atoi(value);
break;

case READ_CHANNELS: /* process rx option */
if (value == NULL) {
printf("error with read channels sub-option\n");

return EXIT_FAILURE;
}

new_channel_config.num_rx_channels = atoi(value);
break;

case WRITE_CHANNELS: /* process tx option */
if (value == NULL) {
printf("error with write channels sub-option\n");

return EXIT_FAILURE;
}

new_channel_config.num_tx_channels = atoi(value);
break;

Expand Down Expand Up @@ -337,6 +355,12 @@ int main (int argc, char* argv[]) {
while (*options != '\0') {
switch (getsubopt(&options, sub_opts, &value)) {
case CHANNEL_ID: /* process id option */
if (value == NULL) {
printf("error with channel id sub-option\n");

return EXIT_FAILURE;
}

new_bitrate_config.id = atoi(value);
break;

Expand All @@ -345,6 +369,12 @@ int main (int argc, char* argv[]) {
int freq;
char units[16];

if (value == NULL) {
printf("error with frequency sub-option\n");

return EXIT_FAILURE;
}

sscanf(value, "%d%s", &freq, units);

if (units[0] == 'k' || units[0] == 'K') {
Expand All @@ -359,31 +389,69 @@ int main (int argc, char* argv[]) {
break;
}
case BPRM: /* process bprm option */
if (value == NULL) {
printf("error with bprm sub-option\n");

return EXIT_FAILURE;
}

new_bitrate_config.bprm = atoi(value);
break;

case TS1: /* process ts1 option */
if (value == NULL) {
printf("error with ts1 sub-option\n");

return EXIT_FAILURE;
}

new_bitrate_config.phase_seg1 = atoi(value);
break;

case TS2: /* process ts2 option */
if (value == NULL) {
printf("error with ts2 sub-option\n");

return EXIT_FAILURE;
}

new_bitrate_config.phase_seg2 = atoi(value);
break;

case SJW: /* process sjw option */
if (value == NULL) {
printf("error with sjw sub-option\n");

return EXIT_FAILURE;
}

new_bitrate_config.sjw = atoi(value);
break;

case BTR0: /* process btr0 option */
{
int btr0;

if (value == NULL) {
printf("error with btr0 sub-option\n");

return EXIT_FAILURE;
}

sscanf(value, "%x", &btr0);
new_bitrate_config.btr0 = btr0;
break;
}
case BTR1: /* process btr1 option */
{
int btr1;

if (value == NULL) {
printf("error with btr1 sub-option\n");

return EXIT_FAILURE;
}

sscanf(value, "%x", &btr1);
new_bitrate_config.btr1 = btr1;
break;
Expand Down Expand Up @@ -449,6 +517,12 @@ int main (int argc, char* argv[]) {
case F81601_EX_CLK: /* f81601 kernel module parameter
for external clock */
{
if (value == NULL) {
printf("error with f81601 external clock sub-option\n");

return EXIT_FAILURE;
}

internal_clk = false;
external_clk = atoi(value);

Expand Down

0 comments on commit 26553fa

Please sign in to comment.