1
0

added more code

This commit is contained in:
Andrew W
2022-08-28 16:12:16 -05:00
parent 5a2894ed1b
commit 7dabaef6f6
2345 changed files with 1343530 additions and 0 deletions

View File

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": []
}
],
"version": 4
}

28
CPE455/lab06/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [
""
],
"stopAtEntry": false,
"cwd": "/home/student/anw0044/CPE455/lab06",
"environment": [],
"program": "/home/student/anw0044/CPE455/lab06/build/Debug/outDebug",
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

30
CPE455/lab06/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,30 @@
{
"C_Cpp_Runner.cCompilerPath": "/usr/bin/gcc",
"C_Cpp_Runner.cppCompilerPath": "/usr/bin/g++",
"C_Cpp_Runner.debuggerPath": "/usr/bin/gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
]
}

Binary file not shown.

Binary file not shown.

BIN
CPE455/lab06/a.out Executable file

Binary file not shown.

10
CPE455/lab06/clang++.txt Normal file
View File

@ -0,0 +1,10 @@
ec3.cpp:11:5: warning: array index 10 is past the end of the array (which contains 10 elements) [-Warray-bounds]
a[10] = 0;
^ ~~
ec3.cpp:8:5: note: array 'a' declared here
char a[10];
^
ec3.cpp:66:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
2 warnings generated.

View File

@ -0,0 +1,13 @@
ec3.cpp:43:10: warning: unused variable 'q' [-Wunused-variable]
int* q = new int;
^
ec3.cpp:11:5: warning: array index 10 is past the end of the array (which contains 10 elements) [-Warray-bounds]
a[10] = 0;
^ ~~
ec3.cpp:8:5: note: array 'a' declared here
char a[10];
^
ec3.cpp:66:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
3 warnings generated.

View File

@ -0,0 +1,48 @@
ec3.cpp:55:5: style: Assignment of function parameter has no effect outside the function. [uselessAssignmentArg]
a = a + 1; // No side effect outside function
^
ec3.cpp:11:6: error: Array 'a[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]
a[10] = 0;
^
ec3.cpp:16:10: error: Array 'a[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]
a[k] = k;
^
ec3.cpp:62:0: error: Found a exit path from function with non-void return type that has missing return statement [missingReturn]
return false;
^
ec3.cpp:33:6: error: Null pointer dereference: x [nullPointer]
*x = 1;
^
ec3.cpp:32:14: note: Assignment 'x=0', assigned value is 0
int* x = 0;
^
ec3.cpp:33:6: note: Null pointer dereference
*x = 1;
^
ec3.cpp:29:6: error: Uninitialized variable: p [uninitvar]
*p = 5;
^
ec3.cpp:47:12: error: Memory is allocated but not initialized: r [uninitdata]
delete r;
^
ec3.cpp:23:14: style: Variable 'a[m]' is assigned a value that is never used. [unreadVariable]
a[m] = m;
^
ec3.cpp:43:12: style: Variable 'q' is assigned a value that is never used. [unreadVariable]
int* q = new int;
^
ec3.cpp:28:10: style: Variable 'p' is not assigned a value. [unassignedVariable]
int* p;
^
ec3.cpp:43:10: style: Variable 'q' is allocated memory that is never used. [unusedAllocatedMemory]
int* q = new int;
^
ec3.cpp:46:10: style: Variable 'r' is allocated memory that is never used. [unusedAllocatedMemory]
int* r = new int[4];
^
ec3.cpp:55:7: style: Variable 'a' is assigned a value that is never used. [unreadVariable]
a = a + 1; // No side effect outside function
^
ec3.cpp:53:0: style: The function 'f' is never used. [unusedFunction]
^

24
CPE455/lab06/cppcheck.txt Normal file
View File

@ -0,0 +1,24 @@
ec3.cpp:11:6: error: Array 'a[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]
a[10] = 0;
^
ec3.cpp:16:10: error: Array 'a[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]
a[k] = k;
^
ec3.cpp:62:0: error: Found a exit path from function with non-void return type that has missing return statement [missingReturn]
return false;
^
ec3.cpp:33:6: error: Null pointer dereference: x [nullPointer]
*x = 1;
^
ec3.cpp:32:14: note: Assignment 'x=0', assigned value is 0
int* x = 0;
^
ec3.cpp:33:6: note: Null pointer dereference
*x = 1;
^
ec3.cpp:29:6: error: Uninitialized variable: p [uninitvar]
*p = 5;
^
ec3.cpp:47:12: error: Memory is allocated but not initialized: r [uninitdata]
delete r;
^

68
CPE455/lab06/ec3.cpp Normal file
View File

@ -0,0 +1,68 @@
void f(int a);
bool g(int& b);
int main(int argc, char* argv[])
{
char a[10];
// Array bounds error
a[10] = 0;
// Array bounds error via loop
for(int k = 0; k <= 10; k++)
{
a[k] = k;
}
// Array bounds error via loop
int m = 0;
while (true)
{
a[m] = m;
m++;
}
// Pointer variable p uninitialized
int* p;
*p = 5;
// Null pointer dereference
int* x = 0;
*x = 1;
// Trigger path in function g that does not return Boolean
int c = -1;
if ( g(c) )
c = 2;
else
c = 3;
// Memory leak
int* q = new int;
// Memory leak
int* r = new int[4];
delete r;
return 0;
}
// Unused function f
void f(int a)
{
a = a + 1; // No side effect outside function
}
// Function g has one path that does not return a Boolean value
bool g(int& b)
{
if (b > 0)
return false;
b = 0;
// Exit without returning a Boolean
}

0
CPE455/lab06/g++.txt Normal file
View File

11
CPE455/lab06/g++all.txt Normal file
View File

@ -0,0 +1,11 @@
ec3.cpp: In function int main(int, char**):
ec3.cpp:8:10: warning: variable a set but not used [-Wunused-but-set-variable]
char a[10];
^
ec3.cpp:43:10: warning: unused variable q [-Wunused-variable]
int* q = new int;
^
ec3.cpp: In function bool g(int&):
ec3.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^

Binary file not shown.