-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces ConcNameAndVersion and ConcDirAndName macros with functions #533
base: master
Are you sure you want to change the base?
Conversation
Replaces ConcNameAndVersion and ConcDirAndName macros with conc_name_and_version and conc_dir_and_name functions respectively, moves the definitions from locfile.h to dsk.c, and adds them to dskdefs.h for use by other source files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @nbriggs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
I am currently reviewing this pull request. In the meanwhile, I am providing a summary of the content of the pull request for you and other reviewers to get up to speed quickly on the changes that have occurred, and the intent behind these changes.
This pull request replaces the ConcNameAndVersion
and ConcDirAndName
macros with conc_name_and_version
and conc_dir_and_name
functions, respectively. The definitions are moved from locfile.h
to dsk.c
, and they are added to dskdefs.h
for use by other source files. This change aims to improve code readability and maintainability by replacing macros with functions.
Highlights
- Macro Replacement: Replaces the
ConcNameAndVersion
andConcDirAndName
macros with functionsconc_name_and_version
andconc_dir_and_name
. - Code Relocation: Moves the definitions of these functions from
locfile.h
todsk.c
. - Header Update: Adds the function declarations to
dskdefs.h
to make them accessible to other source files.
Changelog
- inc/dskdefs.h
- Added declarations for
conc_dir_and_name
andconc_name_and_version
functions (lines 22 and 23).
- Added declarations for
- inc/locfile.h
- Removed the definitions of the
ConcDirAndName
andConcNameAndVersion
macros (lines 431-467 and 486-495).
- Removed the definitions of the
- src/dsk.c
- Removed include of
locfile.h
which contained macro definitions (line 30). - Added definitions for
conc_dir_and_name
(lines 2544-2580) andconc_name_and_version
(lines 2602-2611) functions. - Replaced usages of
ConcNameAndVersion
macro with calls toconc_name_and_version
function inCOM_openfile
(line 378),DSK_getfilename
(lines 890, 930, 979, 1005),DSK_deletefile
(line 1145),DSK_renamefile
(lines 1308, 1323, 1363),COM_getfileinfo
(line 1625),COM_setfileinfo
(line 1814),unixpathname
(line 832),lisppathname
(line 1090), andquote_fname
(line 1189) inufs.c
. - Replaced usages of
ConcDirAndName
macro with calls toconc_dir_and_name
function inDSK_getfilename
(lines 969, 998, 1021),DSK_renamefile
(line 1297),maintain_version
(lines 3309, 3317),get_versionless
(line 3422),check_vless_link
(line 3501),get_old
(lines 3506, 3518, 3546, 3599, 3618, 3705, 3717, 3745, 3770, 3795, 3814, 3826),get_oldest
(lines 3792, 3804, 3832, 3857, 3882, 3901, 3913),get_new
(lines 3989, 3990, 3999, 4024, 4037, 4053, 4086, 4091, 4134, 4153, 4178, 4191), andget_old_new
(lines 4280, 4281, 4288, 4305, 4317, 4333, 4362, 4374, 4413, 4432, 4449, 4461, 4477).
- Removed include of
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Trivia time!
What is the primary difference between a macro and a function in C?
Click here for the answer
Macros are preprocessed, performing textual substitution, while functions are compiled and called at runtime.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request replaces macros with functions, which is a good step towards improving code maintainability and readability. The code is generally well-structured, but there are a few areas that could be improved, particularly regarding string handling safety.
Summary of Findings
- Unsafe string operations: The
conc_name_and_version
function usesstrcpy
andstrcat
which are known to be unsafe if the destination buffer is not large enough to hold the concatenated string. This could lead to buffer overflows and potential security vulnerabilities. - DOS #ifdef placement: The placement of the
#ifdef DOS
block insrc/dsk.c
was moved, but it's unclear if this change was intentional or if it affects the code's behavior under DOS.
Assessment
The pull request replaces the ConcNameAndVersion
and ConcDirAndName
macros with functions, which improves code readability and maintainability. The changes are generally well-structured, but there are a few areas that could be improved. I recommend addressing the comments before merging, and users should have others review and approve this code before merging.
/gemini-review |
Thanks for the pull request! Here's a summary of the changes and some suggestions. Summary General Comments
I didn't find any specific style guide being followed, so I'll assume you're following general C conventions. Here's a summary of the style guide elements referenced in my review:
|
/gemini-review |
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request replaces macros with functions, which is a good practice for improving code maintainability and readability. The changes also include the use of strlcpy
and strlcat
to prevent buffer overflows, which is a good security practice.
Summary of Findings
- Buffer size consistency: Ensure that the buffer size passed to
conc_name_and_version
andconc_dir_and_name
is consistent with the actual buffer size. - String concatenation: Consider using
strlcat
instead ofstrcat
to prevent buffer overflows.
Assessment
The pull request replaces macros with functions to improve code maintainability and readability. The changes also include the use of strlcpy
and strlcat
to prevent buffer overflows, which is a good security practice. However, there are some areas where the code can be further improved, such as ensuring that the size parameters passed to conc_name_and_version
and conc_dir_and_name
are correct and consistent. I recommend addressing these comments before merging, and users should have others review and approve this code before merging.
Replaces ConcNameAndVersion and ConcDirAndName macros with conc_name_and_version and conc_dir_and_name functions respectively, moves the definitions from locfile.h to dsk.c, and adds them to dskdefs.h for use by other source files.
This is not actually ready to merge - testing Google Copilot analysis of pull requests for maiko code.