rewrite uses of strcpy w/ S

This commit is contained in:
EDiasAlberto 2024-06-12 17:02:52 +01:00
parent 9f92eb4766
commit 53f5b05210

View File

@ -21,9 +21,8 @@
//takes inputted char array and returns the integer of the operand, skipping the first character //takes inputted char array and returns the integer of the operand, skipping the first character
//e.g. for a passed "R32", it skips the 'R' and returns 32 //e.g. for a passed "R32", it skips the 'R' and returns 32
int getOperandNumber(char *operand){ int getOperandNumber(char *operand){
char *operandCpy = NULL; char operandCpy[strlen(operand)];
strcpy(operandCpy, operand); strcpy(operandCpy, operand+1);
operandCpy++;
char **endptr = NULL; char **endptr = NULL;
int number = strtol(operandCpy, endptr, 10); int number = strtol(operandCpy, endptr, 10);
return number; return number;
@ -97,9 +96,8 @@ void generateBranchOperands(a64inst_instruction *instr, char* opcode, char *oper
break; break;
case a64inst_CONDITIONAL: case a64inst_CONDITIONAL:
{ {
char *condition = NULL; char condition[strlen(opcode)+1];
condition = strcpy(condition, opcode); strcpy(condition, opcode+2);
condition += 2;
if(strcmp(condition, "eq")==0){ if(strcmp(condition, "eq")==0){
instr->data.BranchData.processOpData.conditionalData.cond = EQ; instr->data.BranchData.processOpData.conditionalData.cond = EQ;
} else if (strcmp(condition, "ne")==0){ } else if (strcmp(condition, "ne")==0){
@ -223,8 +221,8 @@ void parser_instruction(char asmLine[], a64inst_instruction *instr) {
//type is label //type is label
//add to symbol table //add to symbol table
instr->type = a64inst_LABEL; instr->type = a64inst_LABEL;
char *opcodeCpy = NULL; char opcodeCpy[strlen(opcode)+1];
opcodeCpy = strcpy(opcodeCpy, opcode); strcpy(opcodeCpy, opcode);
char *labelData = strtok(opcodeCpy, ":"); char *labelData = strtok(opcodeCpy, ":");
instr->data.LabelData.label = labelData; instr->data.LabelData.label = labelData;
} else { } else {