Project 2 - V&V SW Analysis II
1)
`C:\**\LDRA_workarea\Examples\C_Testbed_examples\Testrain\Testrain.c`. This seems like a Windows file path, but it contains a wildcard character `**`, which typically isn't used in file paths in the same way it's used in Unix-like systems.
However, assuming you want to perform a static code review for the file `Testrain.c` located within the `C_Testbed_examples\Testrain` directory of your LDRA work area, here's a generalized approach:
1. **Access LDRA Workarea**: Navigate to the specified directory within your LDRA work area where the `Testrain.c` file is located.
2. **Code Review Tools**: Use the static code analysis capabilities of LDRA Testbed or any other preferred code analysis tool you have.
3. **Run Static Analysis**: Execute the static code analysis tool on the `Testrain.c` file. This will typically involve specifying the file path or selecting the file from within the tool's interface.
4. **Review Findings**: Once the analysis is complete, review the findings provided by the tool. This may include issues such as coding standard violations, potential bugs, security vulnerabilities, etc.
5. **Generate Report**: Utilize the reporting features of LDRA Testbed or your chosen tool to generate a detailed report summarizing the findings of the static analysis.
6. **Review Report**: Review the generated report to understand the issues detected, their severity, and recommendations for resolution.
7. **Address Issues**: Prioritize and address the identified issues based on their severity and impact on the code.
8. **Document Changes**: Document any changes made to the code based on the findings of the static analysis.
9. **Iterate**: If necessary, iterate the process by re-running the static analysis after making changes to the code to ensure that issues have been resolved.
10. **Upload Report**: If required, upload the generated report to the appropriate platform for sharing with stakeholders.
2)
// cash_register.c
#include <stdio.h>
float total_amount = 0.0;
void process_cash_payment(float amount) {
// Deduct the cash payment amount from the total amount in the cash register
total_amount -= amount;
}
// payment.c
#include <stdio.h>
extern float total_amount;
void process_cash_payment(float amount);
int main() {
// Assume a cash payment of $20
float payment_amount = 20.0;
printf("Processing cash payment...\n");
printf("Total amount before payment: $%.2f\n", total_amount);
process_cash_payment(payment_amount);
printf("Total amount after payment: $%.2f\n", total_amount);
return 0;
}