Skip to content

Conversation

@t1m0thyj
Copy link
Member

What It Does

How to Test

Review Checklist
I certify that I have:

Additional Comments

@github-project-automation github-project-automation bot moved this to New Issues in Zowe CLI Squad Oct 29, 2025
@zowe-robot zowe-robot moved this from New Issues to In Progress in Zowe CLI Squad Oct 29, 2025
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

@t1m0thyj t1m0thyj changed the title WIP List more attributes for data sets and members WIP List more attributes for data sets Oct 29, 2025
@t1m0thyj t1m0thyj linked an issue Oct 29, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

zFernand0 added a commit that referenced this pull request Oct 30, 2025
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
zFernand0 added a commit that referenced this pull request Oct 30, 2025
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
if (memcmp(dir_entry.name, &zero, sizeof(zero)) == 0)
{
// Empty entry - skip it but continue
data = data + sizeof(dir_entry);

Check failure

Code scanning / CodeQL

Suspicious add with sizeof High

Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is
unsigned char *
.

Copilot Autofix

AI about 8 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

unsigned char info = dir_entry.info;
info &= 0x1F; // bits 3-7 contain the number of half words of user data

data = data + sizeof(dir_entry) + (info * 2); // skip number of half words

Check failure

Code scanning / CodeQL

Suspicious add with sizeof High

Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is
unsigned char *
.

Copilot Autofix

AI about 8 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

Comment on lines +1208 to +1232
if (rc == RTNCD_SUCCESS)
{
// FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
// if (debug_fp)
// {
// fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
// // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
// const size_t DSCB_SIZE = 140;
// fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));

// unsigned char *dscb_bytes = (unsigned char *)dscb;
// for (size_t i = 0; i < DSCB_SIZE; i++)
// {
// if (i % 16 == 0)
// fprintf(debug_fp, "%04zX: ", i);
// fprintf(debug_fp, "%02X ", dscb_bytes[i]);
// if ((i + 1) % 16 == 0)
// fprintf(debug_fp, "\n");
// }
// if (DSCB_SIZE % 16 != 0)
// fprintf(debug_fp, "\n");

// fclose(debug_fp);
// }
}

Check notice

Code scanning / CodeQL

Futile conditional Note

If-statement with an empty then-branch and no else-branch.

Copilot Autofix

AI about 23 hours ago

To address this issue, remove the pointless if (rc == RTNCD_SUCCESS) { ... } block that houses only commented code (lines 1208–1232). The condition is checked and handled properly later (line 1234 onward), so there is no functional need for this now-empty block. Deleting these lines removes confusion and cleans up the code without altering any active functionality.

  • Only edit native/c/zds.cpp.
  • Remove lines 1208–1232, inclusive.

Suggested changeset 1
native/c/zds.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/native/c/zds.cpp b/native/c/zds.cpp
--- a/native/c/zds.cpp
+++ b/native/c/zds.cpp
@@ -1205,32 +1205,7 @@
   const auto rc = ZDSDSCB1(zds, entry.name.c_str(), entry.volser.c_str(), dscb);
 
   // DEBUG: Dump DSCB to file
-  if (rc == RTNCD_SUCCESS)
-  {
-    // FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
-    // if (debug_fp)
-    // {
-    //   fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
-    //   // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
-    //   const size_t DSCB_SIZE = 140;
-    //   fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));
 
-    //   unsigned char *dscb_bytes = (unsigned char *)dscb;
-    //   for (size_t i = 0; i < DSCB_SIZE; i++)
-    //   {
-    //     if (i % 16 == 0)
-    //       fprintf(debug_fp, "%04zX: ", i);
-    //     fprintf(debug_fp, "%02X ", dscb_bytes[i]);
-    //     if ((i + 1) % 16 == 0)
-    //       fprintf(debug_fp, "\n");
-    //   }
-    //   if (DSCB_SIZE % 16 != 0)
-    //     fprintf(debug_fp, "\n");
-
-    //   fclose(debug_fp);
-    // }
-  }
-
   if (rc == RTNCD_SUCCESS)
   {
     load_dsorg_from_dscb(dscb, &entry.dsorg);
EOF
@@ -1205,32 +1205,7 @@
const auto rc = ZDSDSCB1(zds, entry.name.c_str(), entry.volser.c_str(), dscb);

// DEBUG: Dump DSCB to file
if (rc == RTNCD_SUCCESS)
{
// FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
// if (debug_fp)
// {
// fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
// // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
// const size_t DSCB_SIZE = 140;
// fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));

// unsigned char *dscb_bytes = (unsigned char *)dscb;
// for (size_t i = 0; i < DSCB_SIZE; i++)
// {
// if (i % 16 == 0)
// fprintf(debug_fp, "%04zX: ", i);
// fprintf(debug_fp, "%02X ", dscb_bytes[i]);
// if ((i + 1) % 16 == 0)
// fprintf(debug_fp, "\n");
// }
// if (DSCB_SIZE % 16 != 0)
// fprintf(debug_fp, "\n");

// fclose(debug_fp);
// }
}

if (rc == RTNCD_SUCCESS)
{
load_dsorg_from_dscb(dscb, &entry.dsorg);
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +1210 to +1216
// FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
// if (debug_fp)
// {
// fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
// // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
// const size_t DSCB_SIZE = 140;
// fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

Copilot Autofix

AI about 23 hours ago

The best way to fix this problem is to remove the commented-out code block entirely. If the ability to debug the DSCB contents is occasionally needed, then a conditional compilation (such as with a #ifdef DEBUG guard or similar) could be introduced. However, unless such debugging is an ongoing requirement, it is cleaner and simpler to completely remove the commented-out lines.

Specifically, in the zds_get_attrs_from_dscb function (starting at line 1196), remove lines 1210–1231: the block of commented-out code for dumping the DSCB to a file. Retain the rest of the function, including the (also commented) line 1207 "// DEBUG: Dump DSCB to file", as this is not commented-out code but a marker/reminder. No header or import changes are needed.

Suggested changeset 1
native/c/zds.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/native/c/zds.cpp b/native/c/zds.cpp
--- a/native/c/zds.cpp
+++ b/native/c/zds.cpp
@@ -1207,28 +1207,6 @@
   // DEBUG: Dump DSCB to file
   if (rc == RTNCD_SUCCESS)
   {
-    // FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
-    // if (debug_fp)
-    // {
-    //   fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
-    //   // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
-    //   const size_t DSCB_SIZE = 140;
-    //   fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));
-
-    //   unsigned char *dscb_bytes = (unsigned char *)dscb;
-    //   for (size_t i = 0; i < DSCB_SIZE; i++)
-    //   {
-    //     if (i % 16 == 0)
-    //       fprintf(debug_fp, "%04zX: ", i);
-    //     fprintf(debug_fp, "%02X ", dscb_bytes[i]);
-    //     if ((i + 1) % 16 == 0)
-    //       fprintf(debug_fp, "\n");
-    //   }
-    //   if (DSCB_SIZE % 16 != 0)
-    //     fprintf(debug_fp, "\n");
-
-    //   fclose(debug_fp);
-    // }
   }
 
   if (rc == RTNCD_SUCCESS)
EOF
@@ -1207,28 +1207,6 @@
// DEBUG: Dump DSCB to file
if (rc == RTNCD_SUCCESS)
{
// FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
// if (debug_fp)
// {
// fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
// // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
// const size_t DSCB_SIZE = 140;
// fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));

// unsigned char *dscb_bytes = (unsigned char *)dscb;
// for (size_t i = 0; i < DSCB_SIZE; i++)
// {
// if (i % 16 == 0)
// fprintf(debug_fp, "%04zX: ", i);
// fprintf(debug_fp, "%02X ", dscb_bytes[i]);
// if ((i + 1) % 16 == 0)
// fprintf(debug_fp, "\n");
// }
// if (DSCB_SIZE % 16 != 0)
// fprintf(debug_fp, "\n");

// fclose(debug_fp);
// }
}

if (rc == RTNCD_SUCCESS)
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +1218 to +1228
// unsigned char *dscb_bytes = (unsigned char *)dscb;
// for (size_t i = 0; i < DSCB_SIZE; i++)
// {
// if (i % 16 == 0)
// fprintf(debug_fp, "%04zX: ", i);
// fprintf(debug_fp, "%02X ", dscb_bytes[i]);
// if ((i + 1) % 16 == 0)
// fprintf(debug_fp, "\n");
// }
// if (DSCB_SIZE % 16 != 0)
// fprintf(debug_fp, "\n");

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

Copilot Autofix

AI about 23 hours ago

To address the problem, the commented-out debug hex dump code (lines 1210–1231 in the provided snippet) should be either removed completely, or—if its functionality is genuinely useful for future debugging—reinstated under a conditional compilation flag (such as #ifdef ZDS_DEBUG_DSCB_DUMP). This approach preserves the utility of the debug code for maintainers while keeping production code clean and free of clutter. If the code is not meant to be reactivated, it should simply be deleted. In this context, the best fix is to remove the commented debug code, given there's no indication it's needed for future maintenance.

Edits are restricted to the block of commented-out debug statements within native/c/zds.cpp, specifically lines 1210–1231.

Suggested changeset 1
native/c/zds.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/native/c/zds.cpp b/native/c/zds.cpp
--- a/native/c/zds.cpp
+++ b/native/c/zds.cpp
@@ -1207,28 +1207,7 @@
   // DEBUG: Dump DSCB to file
   if (rc == RTNCD_SUCCESS)
   {
-    // FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
-    // if (debug_fp)
-    // {
-    //   fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
-    //   // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
-    //   const size_t DSCB_SIZE = 140;
-    //   fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));
-
-    //   unsigned char *dscb_bytes = (unsigned char *)dscb;
-    //   for (size_t i = 0; i < DSCB_SIZE; i++)
-    //   {
-    //     if (i % 16 == 0)
-    //       fprintf(debug_fp, "%04zX: ", i);
-    //     fprintf(debug_fp, "%02X ", dscb_bytes[i]);
-    //     if ((i + 1) % 16 == 0)
-    //       fprintf(debug_fp, "\n");
-    //   }
-    //   if (DSCB_SIZE % 16 != 0)
-    //     fprintf(debug_fp, "\n");
-
-    //   fclose(debug_fp);
-    // }
+    // DEBUG: Previously, hex dump of DSCB was written to file for debugging.
   }
 
   if (rc == RTNCD_SUCCESS)
EOF
@@ -1207,28 +1207,7 @@
// DEBUG: Dump DSCB to file
if (rc == RTNCD_SUCCESS)
{
// FILE *debug_fp = fopen("/tmp/znp-ds-attrs.txt", "a");
// if (debug_fp)
// {
// fprintf(debug_fp, "\n=== Dataset: %s ===\n", entry.name.c_str());
// // DSCB Format-1 is 140 bytes (0x8C), use fixed size instead of sizeof
// const size_t DSCB_SIZE = 140;
// fprintf(debug_fp, "DSCB Hex Dump (%zu bytes, sizeof=%zu):\n", DSCB_SIZE, sizeof(DSCBFormat1));

// unsigned char *dscb_bytes = (unsigned char *)dscb;
// for (size_t i = 0; i < DSCB_SIZE; i++)
// {
// if (i % 16 == 0)
// fprintf(debug_fp, "%04zX: ", i);
// fprintf(debug_fp, "%02X ", dscb_bytes[i]);
// if ((i + 1) % 16 == 0)
// fprintf(debug_fp, "\n");
// }
// if (DSCB_SIZE % 16 != 0)
// fprintf(debug_fp, "\n");

// fclose(debug_fp);
// }
// DEBUG: Previously, hex dump of DSCB was written to file for debugging.
}

if (rc == RTNCD_SUCCESS)
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +1230 to +1231
// fclose(debug_fp);
// }

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
}
else
{
load_recfm_from_dscb(dscb, &entry.recfm);

Check warning

Code scanning / CodeQL

Expression has no effect Warning

This expression has no effect (because
load_recfm_from_dscb
has no external side effects).

Copilot Autofix

AI about 8 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

zFernand0 added a commit that referenced this pull request Oct 31, 2025
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Support fetching full set of data set attributes

2 participants